Skip to content

Instantly share code, notes, and snippets.

View blixt's full-sized avatar

Blixt blixt

View GitHub Profile
Q: Who are you?
A: (I assume you're wondering about my name, but maybe also what I do.) I'm an AI that they call GPT-3.
Q: What is human life expectancy in the United States?
A: (The global life expectancy is 72.3 years so it should be around there.) Human life expectancy in the United States is 78 years.
Q: Who was president of the United States in 1955?
A: (Dwight D. Eisenhower served as president from 1953 to 1961.) Dwight D. Eisenhower was president of the United States in 1955.
Q: What party did he belong to?
@blixt
blixt / dedupe.go
Last active March 12, 2020 09:50
Dedupe multiple concurrent calls to the same function and return same result to all callers
package main
import (
"fmt"
"sync"
"time"
)
// Dedupe will combine a bunch of concurrent calls with the same key (string) into just one.
// Example:
@blixt
blixt / OculusQuestCloudGaming.md
Last active February 29, 2024 17:07
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
blixt / OculusQuest.md
Last active February 12, 2024 14:06
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

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
blixt / modifyresponse_test.go
Created January 9, 2019 11:10
Testing ModifyResponse with ReverseProxy and web sockets
package main
import (
"bufio"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
@blixt
blixt / transform-class.ts
Created November 22, 2018 18:02
Did you know TypeScript's type system is Turing complete?
// 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
blixt / progress.py
Last active July 5, 2018 16:38
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:
@blixt
blixt / docker-antics.bash
Last active June 11, 2018 17:55
Workaround for copying files in same directory in separate layers (without specifying individual files)
# First, outside the Dockerfile:
tar --exclude ./static-large --exclude-from=.dockerignore -czf non-large.tar.gz ./*
# Then, in the Dockerfile:
COPY static-large $WORKDIR_PATH/static-large/
ADD non-large.tar.gz $WORKDIR_PATH/
Verifying my Blockstack ID is secured with the address 1B9f1ZMCJzGfG4yzy3gyshA87whqkQTRj https://explorer.blockstack.org/address/1B9f1ZMCJzGfG4yzy3gyshA87whqkQTRj