Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View richardcornish's full-sized avatar

Richard Cornish richardcornish

View GitHub Profile
@richardcornish
richardcornish / typography.md
Last active November 8, 2023 01:02
Common typographical characters

Cheatsheet of common typographical characters (not an exhaustive reference). HTML character references listed are decimal numeric character references, which are the base-10 equivalent of their corresponding base-16 (hexadecimal) Unicode code point. Also see named character references.

Quotations

Glyph HTML reference Name
‘ Left single quotation mark
’ Right single quotation mark/apostrophe
“ Left double quotation mark
Right double quotation mark
@richardcornish
richardcornish / git.md
Last active August 11, 2023 08:44
Enough Git for your résumé in 100ish lines
@richardcornish
richardcornish / html5_template.html
Last active August 10, 2023 22:02
HTML5 template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<h1>Hello, world!</h1>
</body>
@richardcornish
richardcornish / How to create and inherit objects in JavaScript
Last active December 17, 2015 06:39
Basic notes on how to create and inherit objects the crazy-ass JavaScript way.
/* -------------------------------------------------------
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 () {
@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
@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 / 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 / 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 () {
// 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 / 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