Skip to content

Instantly share code, notes, and snippets.

View chrisparnin's full-sized avatar

Chris Parnin chrisparnin

View GitHub Profile
@dbro
dbro / csvcut
Last active July 25, 2022 18:04 — forked from JoeGermuska/csvcut
Command line 'cut' utility that can handle csv quoting. This allows proper handling of fields that contain delimiters, both field and record delimiters like commas and newlines. Thanks to github.com/JoeGermuska for the initial version of the code.
#!/usr/bin/env python
"""
from https://gist.github.com/JoeGermuska/561347
Like cut, but for CSVs. To be used from a shell command line.
Note that fields are 1-based, similar to the UNIX 'cut' command.
Should use something better than getopt, but this works...
Usage:
@alexnederlof
alexnederlof / deploy.sh
Last active December 21, 2015 21:48
Automatic deployment of your latest Latex (or other) PDF to Amazon S3. The script adds the latest git describe output to the title so that if someone reviews and annotates it, you know which version it was.
#!/bin/bash
#####
#
# Deploy a PDF file annotated with the latest git version
# to your Amazon S3 bucket.
#
# This script requires you are running on a Mac with
# homebrew installed and a S3 bucket setup.
#
@dergachev
dergachev / squid-deb-proxy_on_docker.md
Last active May 25, 2023 03:55
Caching debian package installation with docker

TLDR: I now add the following snippet to all my Dockerfiles:

# If host is running squid-deb-proxy on port 8000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo "HEAD /" | nc `cat /tmp/host_ip.txt` 8000 | grep squid-deb-proxy \
  && (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):8000\";" > /etc/apt/apt.conf.d/30proxy) \
  && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
  || echo "No squid-deb-proxy detected on docker host"
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# [email protected]
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@tzmartin
tzmartin / Info.plist
Created June 24, 2017 19:31 — forked from nathankerr/Info.plist
Registering a Go app as a protocol handler under Mac OS X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>myapp</string>
<key>CFBundleIdentifier</key>
<string>com.pocketgophers.myapp</string>
<key>CFBundleURLTypes</key>
<array>
import imaplib
HOST = "imap.gmail.com"
USER = "[email protected]"
PASSWORD = "---"
BATCH_FOLDER = "Batch"
INBOX_FOLDER = "\\Inbox"
@jawn
jawn / Ideal onboarding braindump.md
Last active July 29, 2023 19:56
Ideal onboarding braindump

In a terminal start a server.

$ python -m SimpleHTTPServer 8000

In another terminal set up the cgroups freezer.

from z3 import *
n = 10
vars = []
def getConstraint(v, x, y):
if x < 0 or x >= n or y < 0 or y >= n:
return False
return v == (1 + vars[x][y])