Skip to content

Instantly share code, notes, and snippets.

@thomas-scrace
thomas-scrace / keybase.md
Last active August 29, 2015 13:57
Keybase proof

Keybase proof

I hereby claim:

  • I am thomas-scrace on github.
  • I am tomscrace (https://keybase.io/tomscrace) on keybase.
  • I have a public key whose fingerprint is 66EA 2235 9E3D 5C75 010A 8925 2687 AD4D 1DBE 8A98

To claim this, I am signing this object:

# Build and install postgres from the git tree.
# This was tested on Ubuntu 14.04 on 19 July 2015
# when the development version of PGSQL was 9.6devel.
sudo apt-get update
sudo apt-get install build-essential libreadline-dev zlib1g-dev git flex bison libxml2-dev libxslt-dev libssl-dev
git clone git://git.postgresql.org/git/postgresql.git
@thomas-scrace
thomas-scrace / testseq.py
Last active December 30, 2015 09:19
Testing 'x in s' performance for various python sequence types
import timeit
seq_types = ('set', 'list', 'tuple')
intervals = (10, 100, 1000)
def test(t, i):
r = t(range(i))
for j in range(i):
if i in r:
pass
@thomas-scrace
thomas-scrace / install-go.sh
Created December 13, 2016 18:02
Download and install the golang tools. Change variables to suit your purposes.
#!/usr/bin/env bash
# Downloads the specified version of go, unpacks it,
# deletes any existing version, and installs the new
# one globally. Needs root.
set -e
INSTALLDIR=/usr/local
GOROOT=$INSTALLDIR/go
VERSION=1.7.4
OS=linux
ARCH=amd64
@thomas-scrace
thomas-scrace / gist:6bdd1bec8d32298c08e923ec5809f364
Created January 27, 2017 11:48
How to download all files from a Gdrive golder using GAM
$ gam user USER_NAME_OF_FILE_OWNER show filelist query "'FILE_ID_OF_FOLDER' in parents" id >files.csv
$ gam csv files.csv gam user ~Owner get drivefile id ~id
>>> properties_dict = {}
>>> for i, row in enumerate(csv.reader(open("Workbook1.csv", "r"))):
... if i == 0:
... continue
... props = row[17].replace("'", '"')
... properties_dict[i] = json.loads(props)
...
>>> for k, v in properties_dict.items():
... print(v["gender"])
...
@thomas-scrace
thomas-scrace / pystart.sh
Created April 22, 2023 19:21
Script to start a new python environment using pyenv. Install latest python. Create a virtualenv. Upgrade pip. usage: pystart.sh name-of-env
#!/bin/bash
env_name=$1
echo "Making new Python environment '$1'"
# Find the latest mainline version of Python available
latest_python=$(pyenv install --list | grep -E "^\s*[3]\.[0-9]+\.[0-9]+$" | grep -v "[a-zA-Z]" | tail -1)
# Strip whitespace:
latest_python=$(echo "$latest_python" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')