Skip to content

Instantly share code, notes, and snippets.

@liquidgenius
liquidgenius / asyncio_loops.py
Created May 10, 2019 01:20 — forked from lars-tiede/asyncio_loops.py
asyncio + multithreading: one asyncio event loop per thread
import asyncio
import threading
import random
def thr(i):
# we need to create a new loop for the thread, and set it as the 'default'
# loop that will be returned by calls to asyncio.get_event_loop() from this
# thread.
loop = asyncio.new_event_loop()
@liquidgenius
liquidgenius / download.py
Created May 9, 2019 16:07 — forked from garnaat/download.py
Use multiprocess to download objects from S3
"""
"""
import multiprocessing
import boto
import os
import sys
import datetime
import logging
import Queue
@liquidgenius
liquidgenius / docker-help.md
Created April 30, 2019 06:34 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@liquidgenius
liquidgenius / s3gzip.py
Created March 18, 2019 22:29 — forked from veselosky/s3gzip.py
How to store and retrieve gzip-compressed objects in AWS S3
# vim: set fileencoding=utf-8 :
#
# How to store and retrieve gzip-compressed objects in AWS S3
###########################################################################
#
# Copyright 2015 Vince Veselosky and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@liquidgenius
liquidgenius / boto3-gzip.py
Created March 18, 2019 22:25 — forked from tobywf/boto3-gzip.py
GZIP compressing files for S3 uploads with boto3
from io import BytesIO
import gzip
import shutil
def upload_gzipped(bucket, key, fp, compressed_fp=None, content_type='text/plain'):
"""Compress and upload the contents from fp to S3.
If compressed_fp is None, the compression is performed in memory.
"""
@liquidgenius
liquidgenius / sampleREADME.md
Created September 11, 2018 16:09 — forked from FrancesCoronel/sampleREADME.md
A sample README for all your GitHub projects.

FVCproductions

INSERT GRAPHIC HERE (include hyperlink in image)

Repository Title Goes Here

Subtitle or Short Description Goes Here

@liquidgenius
liquidgenius / README-Template.md
Created September 11, 2018 16:05 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@liquidgenius
liquidgenius / csv-to-shapefile-geopandas.py
Created August 9, 2018 20:06 — forked from nygeog/csv-to-shapefile-geopandas.py
Read a CSV with Pandas and set as GeoDataFrame with geopandas and save as Shapefile with fiona
import pandas as pd
from geopandas import GeoDataFrame
from shapely.geometry import Point
import fiona
df = pd.read_csv('data.csv')
geometry = [Point(xy) for xy in zip(df.x, df.y)]
crs = {'init': 'epsg:2263'} #http://www.spatialreference.org/ref/epsg/2263/
geo_df = GeoDataFrame(df, crs=crs, geometry=geometry)
@liquidgenius
liquidgenius / inflate.py
Created August 7, 2018 18:02 — forked from fmder/inflate.py
Inflate a flattened dictionary
def inflate(d, sep="_"):
items = dict()
for k, v in d.items():
keys = k.split(sep)
sub_items = items
for ki in keys[:-1]:
try:
sub_items = sub_items[ki]
except KeyError:
@liquidgenius
liquidgenius / sqlite3-example.py
Created August 7, 2018 00:15 — forked from gka/sqlite3-example.py
The code below does the same as the example snippet you've just seen: opening a database connection, creating a new table with some columns, storing some data, altering the table schema and adding another row.
import sqlite3
# open connection and get a cursor
conn = sqlite3.connect(':memory:')
c = conn.cursor()
# create schema for a new table
c.execute('CREATE TABLE IF NOT EXISTS sometable (name, age INTEGER)')
conn.commit()