Skip to content

Instantly share code, notes, and snippets.

View Miserlou's full-sized avatar

Rich Jones Miserlou

View GitHub Profile
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 11, 2024 17:14
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@florianhartig
florianhartig / copyInstalledPackages.r
Last active June 15, 2022 08:29
Script to copy the packages installed on one computer or R version to another. Originally from http://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r-on-windows
# modified from http://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r-on-windows
# run on old computer / r version
setwd("/Users/Florian/Dropbox/temp") # or any other existing temp directory
packages <- installed.packages()[,"Package"]
save(packages, file="Rpackages")
# run on new computer / r version
setwd("/Users/Florian/Dropbox/temp") # or any other existing temp directory
@pinceladasdaweb
pinceladasdaweb / imgur.js
Created March 27, 2014 13:14
Upload images to imgur via JavaScript
/*
--------------------------------
imgur Upload
--------------------------------
+ https://github.com/pinceladasdaweb/imgur-upload
+ version 1.1
+ Copyright 2014 Pedro Rogerio
+ Licensed under the MIT license
+ Documentation: https://github.com/pinceladasdaweb/imgur-upload
@nkrumm
nkrumm / aspera_to_s3.sh
Created December 23, 2013 07:14
DIY Direct-to-S3 Aspera solution. This snipped monitors a directory for new files (uploaded via aspera, for example) and then starts a background s3cmd job to upload those files Using the --partial-file-suffix=.part for the ascp command ensures that inotifywait only gets trigger when the file is finished uploading.
inotifywait -m -e moved_to $BASE | while read line
do
F=$(echo $line | cut -f3 -d" ")
echo "Now uploading $F"
s3cmd --force --no-progress put $F s3://mybucket/ &
done
@mboersma
mboersma / DockerMacClient.md
Last active May 26, 2017 06:43
Build Docker on Mac OS X and run it as a client connected to a Linux VM running the docker daemon.

Run Docker client on Mac OS X connected to a Linux VM

Official Mac Docker Binary!

None of this is really necessary now that the Docker team is releasing official Mac OS X binary builds. Please see moby/moby#3337 for details.

@iepathos
iepathos / sorting_example_by_subdict_key
Last active May 4, 2018 15:11
Explicitly sorting a dictionary by a sub-dictionary subkey into an ordered list.
# Dictionaries are inherently orderless, but lists are ordered!
import collections
d = { '123': { 'key1': 3, 'key2': 11, 'key3': 3 },
'124': { 'key1': 6, 'key2': 56, 'key3': 6 },
'125': { 'key1': 7, 'key2': 44, 'key3': 9 } }
results_list = []
sort_by_dict = {}
@wsargent
wsargent / docker_cheat.md
Last active August 31, 2023 12:10
Docker cheat sheet
@philchristensen
philchristensen / django.cgi.py
Last active March 13, 2022 00:53
A very slow way to serve Django when all you have is CGI
#!/usr/bin/env python
# encoding: utf-8
"""
django.cgi
A simple cgi script which uses the django WSGI to serve requests.
Code copy/pasted from PEP-0333 and then tweaked to serve django.
http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side
@bonsaiviking
bonsaiviking / sha2.py
Created June 13, 2013 16:54
Pure-python SHA-2 implementation, including all FIPS 180-2 specified variants (SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256)
#!/usr/bin/env python
import struct
def rightrotate(i, n, wsize):
return ((i << (wsize-n)) & (2**wsize-1)) | (i >> n)
class SHA2(object):
"""Abstract class for SHA-2 variants"""
def __init__(self):
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: