Skip to content

Instantly share code, notes, and snippets.


Blixt blixt

Block or report user

Report or block blixt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
blixt / prng.js
Created Jul 29, 2014
A very simple, seedable JavaScript PRNG.
View prng.js
* Creates a pseudo-random value generator. The seed must be an integer.
* Uses an optimized version of the Park-Miller PRNG.
function Random(seed) {
this._seed = seed % 2147483647;
if (this._seed <= 0) this._seed += 2147483646;
blixt /
Created Aug 16, 2014
How to add CORS support to a Flask app in 9 lines of code
def add_cors_headers(response):
response.headers['Access-Control-Allow-Origin'] = '*'
if request.method == 'OPTIONS':
response.headers['Access-Control-Allow-Methods'] = 'DELETE, GET, POST, PUT'
headers = request.headers.get('Access-Control-Request-Headers')
if headers:
response.headers['Access-Control-Allow-Headers'] = headers
return response
blixt / logger_middleware.go
Last active Sep 14, 2019
Logger middleware for Go HTTP servers which logs every request with response status code in the Apache format.
View logger_middleware.go
package main
import (
blixt /
Last active Aug 27, 2019
Playing SteamVR games on the Oculus Quest

Playing SteamVR games on the Oculus Quest, without owning a PC

Setting up your Virtual Machine

We'll be creating a new Virtual Machine on Microsoft's cloud platform, Azure. The VM will have a beefy GPU just like a home computer so it can be used for playing games.

  1. Go to [the Azure portal][azure] and sign up or log in.

  2. If you are on a Free account, first go to Subscriptions and upgrade it to a Pay-as-you-go plan. Don't worry, you will get to keep any free credits you have. Azure's interface is a bit slow so this will take a minute.

    ⚠️ Make sure to not include any support plan because they will charge you monthly!

blixt /
Last active Jul 10, 2019
Testing random number generators with DieHarder

Testing RNGs with Dieharder

This guide is specifically for pseudo-random number generators (PRNGs) written in JavaScript, and tested in Mac OS X.



blixt /
Last active Jun 6, 2019
Streaming Oculus Quest wirelessly over WiFi to macOS (on a MacBook)

Streaming an Android-based VR headset to your computer

Setting it up the first time

The first time you have to set it up with a cable. The Oculus Quest has a USB-C port (the one used for charging). Use this to connect to your computer.

Preparing your Oculus Quest

Your Quest needs to be in Developer mode. This is super easy, just open your companion app on your phone and go to Settings and enable Developer

View useIO.ts
import { useEffect, useRef, useState } from "react"
interface IO<T> {
setters: ((value: T) => void)[]
update: (value: T) => void
value: T | undefined
const store: { [name: string]: IO<any> | undefined } = {}
blixt / modifyresponse_test.go
Created Jan 9, 2019
Testing ModifyResponse with ReverseProxy and web sockets
View modifyresponse_test.go
package main
import (
blixt / transform-class.ts
Created Nov 22, 2018
Did you know TypeScript's type system is Turing complete?
View transform-class.ts
// Return a type with only the methods of T that return R.
type MethodsWithReturnType<T, R> = {
[P in keyof T]: T[P] extends () => infer RR ? (RR extends R ? P : never) : never
}[keyof T]
// Filter away all keys except methods that return void and
// return a new type with those methods returning booleans.
type VoidMethodsToBoolMethods<T> = { [P in MethodsWithReturnType<T, void>]: () => boolean }
// Our test input class:
blixt /
Last active Jul 5, 2018
Simple progress indicator copy/paste function for Python scripts
# -*- coding: utf-8 -*-
import sys
_last_status = None
_last_status_permille = 0
def print_status(status=None, fraction=0):
global _last_status, _last_status_permille
permille = int(fraction * 1000)
if status != _last_status:
You can’t perform that action at this time.