Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Cornish richardcornish

View GitHub Profile
@richardcornish
richardcornish / Git notes
Last active Mar 4, 2020
Enough Git for your résumé in 100ish lines
View Git notes
Start
=====
1. Install Git
http://git-scm.com/download/mac
(But consider using Homebrew)
2. Make a GitHub account
https://github.com/
3. Open Terminal
@richardcornish
richardcornish / Typography cheat sheet
Last active Sep 13, 2017
These character sets are not exhaustive, but merely a quick reference for common characters.
View Typography cheat sheet
These character sets are not exhaustive, but merely a quick reference for common characters.
Quotation
‘ ‘ \2018 Left single quotation mark
’ ’ \2019 Right single quotation mark/Apostrophe
“ “ \201C Left double quotation mark
” ” \201D Right double quotation mark
' ' \0027 Typewriter single quotation mark
" " \0022 Typewriter double quotation mark
′ ′ \2032 Prime (Feet / Minutes)
@richardcornish
richardcornish / gist:ec833827a0612f1c311a02ec4b299612
Last active Jul 17, 2017
Create new Python package for PyPi
View gist:ec833827a0612f1c311a02ec4b299612
# 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
View gist:0533b67d85752a66f4e75a0357eda28a
git remote add upstream https://github.com/<user>/<repo>.git
git fetch upstream
git checkout master
git merge upstream/master
git push
@richardcornish
richardcornish / Django install
Last active Aug 24, 2016
The absolute bare minimum to run Django (requires Python, SQLite, pip, and virtualenv)
View Django install
virtualenv myproject
source myproject/bin/activate
pip install django
cd myproject/
django-admin startproject myproject
cd myproject/
python manage.py migrate
python manage.py runserver
@richardcornish
richardcornish / MySQLgenerator
Last active Apr 19, 2016
Bash script that quickly generates a MySQL database, user, and password
View MySQLgenerator
#!/bin/bash
# Usage:
# $ brew install mysql
# $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# $ bash -c "$(curl -fsSL https://gist.githubusercontent.com/richardcornish/e9093757a6977b1b6b5b/raw)"
echo "Welcome to the MySQL generator!"
read -p "Database name: " dbname
read -p "Database user: " dbuser
@richardcornish
richardcornish / forms.py
Last active Jan 19, 2016
Breaking Django's form wizard (GenderFormBasic) out across views by manually hacking HiddenInput and RadioSelect
View forms.py
from __future__ import absolute_import
from django import forms
from django.contrib.auth import get_user_model
from django.utils.safestring import mark_safe
from utils.mixins import NoLabelSuffixMixin
from .utils import HiddenInput, RadioSelect
User = get_user_model()
@richardcornish
richardcornish / How to create and inherit objects in JavaScript
Last active Dec 17, 2015
Basic notes on how to create and inherit objects the crazy-ass JavaScript way.
View How to create and inherit objects in JavaScript
/* -------------------------------------------------------
Old-school way to create child objects from parent objects
--------------------------------------------------------*/
var Person = function (name, age, sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
Person.prototype.sayGreeting = function () {
View HTML5 template
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style>
body { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
@richardcornish
richardcornish / Quest mode in Google Maps
Created Apr 20, 2012
How to add the Quest mode in Google Maps from April Fools Day 2012
View Quest mode in Google Maps
// Set map options
var mapOptions = {
center: new google.maps.LatLng(41.917142, -87.673837), // Or whatever
zoom: 15,
mapTypeId: "quest",
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, "quest"]
},
scrollwheel: false
}