Skip to content

Instantly share code, notes, and snippets.

Avatar
🚲
Inventing

Alexey Novikov velocityzen

🚲
Inventing
View GitHub Profile
@JohnSundell
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
0xjac / private_fork.md
Last active Oct 28, 2020
Create a private fork of a public repository
View private_fork.md

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 git@github.com:usi-systems/easytrace.git
@eevee
eevee / perlin.py
Last active Oct 26, 2020
Perlin noise in Python
View perlin.py
"""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
interpolating.
@bendc
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
justinbellamy / cltools.sh
Last active Oct 7, 2020 — forked from jellybeansoup/cltools.sh
Install Autoconf and Automake on OS X El Capitan
View cltools.sh
#!/bin/sh
##
# 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 http://jsdelfino.blogspot.com.au/2012/08/autoconf-and-automake-on-mac-os-x.html
#
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
View deepdream-install.md
#!/usr/bin/env bash

# Assuming OS X Yosemite 10.10.4

# Install XCode and command line tools
# See https://itunes.apple.com/us/app/xcode/id497799835?mt=12#
# See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
xcode-select --install
@TrevorJTClarke
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 (){
// http://www.youtube.com/embed/m5yCOSHeYn4
var ytRegEx = /^(?:https?:\/\/)?(?:i\.|www\.|img\.)?(?:youtu\.be\/|youtube\.com\/|ytimg\.com\/)(?:embed\/|v\/|vi\/|vi_webp\/|watch\?v=|watch\?.+&v=)((\w|-){11})(?:\S+)?$/;
// http://vimeo.com/3116167, https://player.vimeo.com/video/50489180, http://vimeo.com/channels/3116167, http://vimeo.com/channels/staffpicks/113544877
var vmRegEx = /https?:\/\/(?:vimeo\.com\/|player\.vimeo\.com\/)(?:video\/|(?:channels\/staffpicks\/|channels\/)|)((\w|-){7,9})/;
@RTC1
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
staltz / introrx.md
Last active Oct 28, 2020
The introduction to Reactive Programming you've been missing
View introrx.md
You can’t perform that action at this time.