Skip to content

Instantly share code, notes, and snippets.

View kennethjmyers's full-sized avatar

Ken kennethjmyers

  • NYC
View GitHub Profile
@pedrovgp
pedrovgp / upsert_df.py
Last active February 11, 2024 20:44
Allow upserting a pandas dataframe to a postgres table (equivalent to df.to_sql(..., if_exists='update')
# Upsert function for pandas to_sql with postgres
# https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/8702291#8702291
# https://www.postgresql.org/docs/devel/sql-insert.html#SQL-ON-CONFLICT
import pandas as pd
import sqlalchemy
import uuid
import os
def upsert_df(df: pd.DataFrame, table_name: str, engine: sqlalchemy.engine.Engine):
@gwerbin
gwerbin / conda_env_export.py
Last active March 6, 2024 06:23
Export a Conda environment with --from-history, but also append Pip-installed dependencies
"""
Export a Conda environment with --from-history, but also append
Pip-installed dependencies
Exports only manually-installed dependencies, excluding build versions, but
including Pip-installed dependencies.
Lots of issues requesting this functionality in the Conda issue tracker,
e.g. https://github.com/conda/conda/issues/9628
@marioaquino
marioaquino / tmux.conf
Last active September 25, 2020 16:31
This tmux config includes mouse click for window selection, wheel scrolling, custom leader key, and OS-level copy/paste support
# Make Ctrl+\ the tmux leader combination
unbind C-b
set -g prefix "C-\\"
bind "C-\\" send-prefix
setw -g xterm-keys on
set -g default-terminal "screen-256color"
set -sg escape-time 0
set -g base-index 1
@shentonfreude
shentonfreude / dynamodb_read_backoff.py
Created December 11, 2015 17:00
Wrap boto3 dynamodb in an exponential backoff to avoid ProisionedThroughputExceededException
#!/usr/bin/env python
# An exponential backoff around Boto3 DynamoDB, whose own backoff eventually
# fails on long multipage scans. We'd like to use this as a wrapper somehow,
# see: https://gist.github.com/numberoverzero/cec21b8ca715401c5662
from time import sleep
import boto3
from boto3.dynamodb.conditions import Attr
@michaelgodshall
michaelgodshall / install_textblob_corpora
Last active March 5, 2016 23:48
How to Install Texblob NLTK Corpora on Heroku
#!/usr/bin/env bash
# Put this file in the `bin` directory at the root of your project
source $BIN_DIR/utils
echo "-----> Starting corpora installation"
# Assumes NLTK_DATA environment variable is already set
# $ heroku config:set NLTK_DATA='/app/nltk_data'
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 10, 2024 16:49
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@dAnjou
dAnjou / flask-upload
Created June 5, 2012 12:35
Flask upload example
<VirtualHost *>
ServerName example.com
WSGIDaemonProcess www user=max group=max threads=5
WSGIScriptAlias / /home/max/Projekte/flask-upload/flask-upload.wsgi
<Directory /home/max/Projekte/flask-upload>
WSGIProcessGroup www
WSGIApplicationGroup %{GLOBAL}
Order deny,allow