Skip to content

Instantly share code, notes, and snippets.


Alexey Novikov velocityzen

View GitHub Profile
JohnSundell / Perform.swift
Last active Dec 21, 2019
A function that enables you to easily wrap throwing APIs, to provide a custom error
View Perform.swift
* Perform a throwing expression, and throw a custom error in case the expression threw
* - parameter expression: The expression to execute
* - parameter error: The custom error to throw instead of the expression's error
* - throws: The given error
* - returns: The return value of the given expression
func perform<T>(_ expression: @autoclosure () throws -> T, orThrow errorExpression: @autoclosure () -> Error) throws -> T {
do {
0xjac /
Last active Oct 28, 2020
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)
    git clone --bare
eevee /
Last active Oct 26, 2020
Perlin noise in Python
"""Perlin noise implementation."""
# Licensed under ISC
from itertools import product
import math
import random
def smoothstep(t):
"""Smooth curve with a zero derivative at 0 and 1, making it useful for
bendc / iterable.js
Created Jan 26, 2016
Make objects iterable
View iterable.js
const iterable = function* (obj) {
yield* Object.keys(obj).map(key => [key, obj[key]]);
justinbellamy /
Last active Oct 7, 2020 — forked from jellybeansoup/
Install Autoconf and Automake on OS X El Capitan
# Install autoconf, automake and libtool smoothly on Mac OS X.
# Newer versions of these libraries are available and may work better on OS X
# This script is originally from
export build=~/devtools # or wherever you'd like to build
View TBezierInterpolation.cpp
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;
#define EPSILON 1.0e-5
#define RESOLUTION 32
class Point2D
#!/usr/bin/env bash

# Assuming OS X Yosemite 10.10.4

# Install XCode and command line tools
# See
# See
xcode-select --install
TrevorJTClarke / MediaFormat
Last active May 28, 2020
MediaFormat - A regex system for finding the media ID for each type of popular social site. Can identify YouTube, Vimeo, Spotify, and Soundcloud.
View MediaFormat
* MediaFormat
* format and return only needed pieces of media from their public sources
* Author: Trevor Clarke
function MediaFormat (){
var ytRegEx = /^(?:https?:\/\/)?(?:i\.|www\.|img\.)?(?:youtu\.be\/|youtube\.com\/|ytimg\.com\/)(?:embed\/|v\/|vi\/|vi_webp\/|watch\?v=|watch\?.+&v=)((\w|-){11})(?:\S+)?$/;
var vmRegEx = /https?:\/\/(?:vimeo\.com\/|player\.vimeo\.com\/)(?:video\/|(?:channels\/staffpicks\/|channels\/)|)((\w|-){7,9})/;
RTC1 / gist:89d7f95555be8cf7d1aa
Created Jun 27, 2014
CacheBuster NGINX Rule 1
View gist:89d7f95555be8cf7d1aa
location ~* "^(.+)-[0-9a-f]{32}(\.(.*))$" {
try_files $uri $1$2 =404;
staltz /
Last active Oct 28, 2020
The introduction to Reactive Programming you've been missing
You can’t perform that action at this time.