⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import time | |
# inspiration: https://mathematica.stackexchange.com/questions/39361/how-to-generate-a-random-snowflake | |
# see https://www.redblobgames.com/grids/hexagons/ for information | |
# about hexagon grids and coordinate systems | |
# neighbors in axial coordinates | |
DIRS = [(1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1), (0, 1)] |
Find the fonts you want to copy:
# Show hidden files in Finder
defaults write com.apple.finder AppleShowAllFiles YES
# Location of Typekit Synced fonts
cd /Users/daveaspinall/Library/Application\ Support/Adobe/CoreSync/plugins/livetype/.r
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import struct | |
def main(): | |
with open('DRAKS0005.sl2', 'rb') as fo: | |
fo.seek(0x2c0, 0) | |
for slot in range(0, 10): | |
fo.seek(0x100, 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go PubSub Server | |
// | |
// Usage - Subscribing: | |
// var conn = new EventSource('/subscribe'); | |
// conn.addEventListener('message', function(e){ alert(e.data); }, false); | |
// | |
// Usage - Publishing: | |
// curl http://localhost:8080/publish -F 'msg=Hello World' | |
package main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def paragraph(min=1, max=20): | |
def sentence(): | |
nouns = ["time", "person", "year", "way", "day", "thing", "man", "world", | |
"life", "hand", "part", "child", "eye", "woman", "place", "work", "week", | |
"case", "point", "government", "company", "number", "group", "problem", "fact"] | |
verbs = ["be", "have", "do", "say", "get", "make", "go", "know", "take", | |
"see", "come", "think", "look", "want", "give", "use", "find", "tell", "ask", | |
"work", "seem", "feel", "try", "leave", "call"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
var insertAtCaret = function(value) { | |
if (document.selection) { // IE | |
this.focus(); | |
sel = document.selection.createRange(); | |
sel.text = value; | |
this.focus(); | |
} | |
else if (this.selectionStart || this.selectionStart == '0') { | |
var startPos = this.selectionStart; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
function dragEnter(e) { | |
$(e.target).addClass("dragOver"); | |
e.stopPropagation(); | |
e.preventDefault(); | |
return false; | |
}; | |
function dragOver(e) { | |
e.originalEvent.dataTransfer.dropEffect = "copy"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var user = { | |
validateCredentials: function (username, password) { | |
return ( | |
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' } | |
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' } | |
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' } | |
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' } | |
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' } | |
: false | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this will install everything as root, so take that into account before you run it | |
# need cmake, python development headers, ZLib and OpenSSL | |
sudo apt-get install cmake python2.7-dev zlib1g-dev libssl-dev | |
mkdir libgit && cd libgit | |
git clone git://github.com/libgit2/libgit2.git | |
cd libgit2 |
NewerOlder