Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View marksteve's full-sized avatar
🏠

Mark Steve Samson marksteve

🏠
View GitHub Profile
@fogleman
fogleman / snowflake.py
Last active December 28, 2021 00:21
Snowflake Generator
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)]

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ 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,

@daveaspinall
daveaspinall / typekit-sync.md
Last active July 17, 2018 09:54
Save Typekit sync fonts to new location

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
@eur0pa
eur0pa / eur0pa-dks_deathtoll.py
Last active October 7, 2022 14:00
Dark Souls Deaths Counter
#!/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)
@maccman
maccman / pubsub.go
Last active December 15, 2016 22:30
// 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
@typehorror
typehorror / loreming.py
Created November 26, 2012 06:35
I recently wanted to generate data for a project I'm working on. Lorem ipsum offers a package but I really think it is "oversized" for what I needed: generating random text content that looks human.
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"]
(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;
(function($){
function dragEnter(e) {
$(e.target).addClass("dragOver");
e.stopPropagation();
e.preventDefault();
return false;
};
function dragOver(e) {
e.originalEvent.dataTransfer.dropEffect = "copy";
@nijikokun
nijikokun / example-user.js
Created May 3, 2012 20:46
Beautiful Validation... Why have I never thought of this before?!
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
);
@Problematic
Problematic / install_pygit.sh
Created February 10, 2012 23:56
Installing pygit2 on Ubuntu 11.10
# 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