Skip to content

Instantly share code, notes, and snippets.

View poliquin's full-sized avatar

Chris poliquin

  • Los Angeles, CA, USA
View GitHub Profile
@poliquin
poliquin / read_delim_nul.R
Created February 4, 2022 05:59
Read text file with NULL bytes in R
read_delim_nul <- function(path, encoding = 'utf8', ...) {
#' Read a delimited text file that contains NULL bytes.
#'
#' @param path One or more file paths.
#' @param encoding File encoding.
#' @param ... Arguments to read_delim.
# can process multiple file paths
if (length(path) > 1) {
return(
@poliquin
poliquin / e3tag.py
Created August 31, 2021 20:01
Simple command line tool for computing S3 ETag
import hashlib
"""
Calculate Amazon S3 ETag for one or more files.
Example:
python e3tag.py files/1.txt files/2.txt files/3.txt
"""
@poliquin
poliquin / tmux.md
Created June 3, 2020 06:04 — forked from andreyvit/tmux.md
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

@poliquin
poliquin / mariadb-docker-digitalocean.md
Last active June 15, 2024 17:59
Using MariaDB via Docker on Digital Ocean

Notes on MariaDB and Docker

These notes describe how to start a MariaDB container with Docker on a Digital Ocean droplet running Ubuntu.

Installing Docker

Follow the instructions for [Docker CE on Ubuntu][0]:

@poliquin
poliquin / open_file_neovim_iterm.applescript
Created August 20, 2017 15:14
Open selected file in Finder with neovim using iTerm2
-- Open selected file using neovim in an iTerm2 window
-- Requires iTerm2 version 2.9+
(* Install:
*
* (1) Save this script as an Application
* (2) Cmd + drag the application to Finder toolbar
* (3) Click the new shortcut to open selected file in neovim using iTerm2
*)
@poliquin
poliquin / usa_states.tsv
Last active May 24, 2024 17:44
Identifiers for United States
usps fips alphanum state_name cen_division cen_region
AL 1 1 Alabama East South Central South
AK 2 2 Alaska Pacific West
AZ 4 3 Arizona Mountain West
AR 5 4 Arkansas West South Central South
CA 6 5 California Pacific West
CO 8 6 Colorado Mountain West
CT 9 7 Connecticut New England Northeast
DE 10 8 Delaware South Atlantic South
DC 11 9 District of Columbia South Atlantic South
@poliquin
poliquin / reservoir.py
Created June 24, 2016 20:49
Reservoir sampling of file or stdin in Python 2/3
#!/usr/bin/env python
import sys
import random
from itertools import islice
"""
Reservoir sampling of input file/stream. Handles header rows.
"""
@poliquin
poliquin / fifty_folders.sh
Last active May 16, 2016 01:09
Make a folder for each of the 50 states
#!/bin/bash
# Make a folder for each of the 50 states
mkdir -p al-alabama
mkdir -p ak-alaska
mkdir -p az-arizona
mkdir -p ar-arkansas
mkdir -p ca-california
mkdir -p co-colorado
mkdir -p ct-connecticut
@poliquin
poliquin / stata-import-delimited.do
Created April 22, 2016 03:28
Importing a CSV file with double quotes in the data into Stata
// Reading CSV data into Stata is sometimes complicated by the presence of double quotes.
// The import delimited command often provides the solution:
import delim "data.csv", clear delim(",") varn(1) charset("utf8")
@poliquin
poliquin / open_finder_in_iterm.applescript
Created April 15, 2016 16:30
Launch iTerm2 window from Finder using AppleScript
-- Open new iTerm2 window and navigate to current Finder directory
-- Requires iTerm2 version 2.9+
(* Install:
*
* (1) Save this script as an Application
* (2) Cmd + drag the application to Finder toolbar
* (3) Click the new shortcut to open iTerm2 window in current directory
*)