Skip to content

Instantly share code, notes, and snippets.

View richardcornish's full-sized avatar

Richard Cornish richardcornish

View GitHub Profile
@richardcornish
richardcornish / tar.md
Created January 14, 2024 23:08
Extract and create archive files

tar

Extract and create archive files

Extract

  • -x Extract
  • -z (De)compress archive with gzip
  • -v Verbose
  • -f Location of archive
@richardcornish
richardcornish / install_python.md
Last active October 5, 2023 01:18
Build and install Python and configuration options with pyenv

Install Xcode Command Line Tools.

xcode-select --install

Install Homebrew.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@richardcornish
richardcornish / design_processes.md
Last active August 10, 2023 21:52
The UX of UX: a comparison of design processes
@richardcornish
richardcornish / python_packaging.md
Last active August 10, 2023 21:53
Python packaging cheatsheet

Create

First time only.

mkdir myproject
cd myproject/
python -m venv venv
source venv/bin/activate
git clone [email protected]:username/myproject.git
@richardcornish
richardcornish / gist:ec833827a0612f1c311a02ec4b299612
Last active July 17, 2017 17:51
Create new Python package for PyPi
# Create environment
mkvirtualenv -p python3 mydjangopackage
pip install django sphinx sphinx-autobuild sphinx-rtd-theme
# Create demo environment
mkvirtualenv -p python3 mydjangopackagedemo
pip install django gunicorn psycopg2 whitenoise dj-database-url
# Create docs
mkdir docs
// One global variable for all your JavaScript
var MY_SITE = window.MY_SITE || {};
// Requires jQuery
// Global jQuery object is aliased to avoid polluting global namespace with "$"
MY_SITE = (function ($) {
'use strict';
var private_function;
@richardcornish
richardcornish / add.js
Last active August 10, 2023 21:35
Uses variable-length arguments and closures to create an adding adding function
// H5BP Front-end Developer Interview Questions
// https://github.com/h5bp/Front-end-Developer-Interview-Questions#jscode
// Usage:
// 1 = add(1)();
// 3 = add(1, 2)();
// 6 = add(1, 2)(3);
// 10 = add(1, 2)(3, 4);
// 0 = add()();
var add = function () {
@richardcornish
richardcornish / javascript_madness.md
Last active August 10, 2023 21:39
An incomplete list of bizarre failings of the JavaScript programming language
  • Prototypal inheritance forces an unstated empty object onto your object with key prototype
  • functions can act as object constructors but with the same syntax
  • empty array members break loops
  • Infinity/-Infinity
  • +0/-0
  • null is an object
  • testing NaN === NaN is always false
  • typeof always returns object" for all different reference types
  • the type of NaN (not a number) is literally "number" but as a string
  • void looks like a Java class but its only job is to return undefined
@richardcornish
richardcornish / GitHub pages branch
Last active August 29, 2015 14:07
Creates a gh-pages branch based on a gh-pages directory, and serves its contents as a <username>.github.io website
# First time
mkdir gh-pages
touch gh-pages/index.html
git add gh-pages
git commit -m "First commit of GitHub Pages branch"
git push origin master
# Subsequent times
# Edit, save, commit, push files inside gh-pages directory
git subtree push --prefix gh-pages origin gh-pages
@richardcornish
richardcornish / subl.sh
Last active August 10, 2023 22:05
Sublime Text CLI `subl` shortcut
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl