Skip to content

Instantly share code, notes, and snippets.

View sporsh's full-sized avatar

Geir Sporsheim sporsh

View GitHub Profile
@sporsh
sporsh / Dockerfile
Last active August 3, 2022 20:03
WebAssembly SDF rendering
FROM silkeh/clang:14 as build
WORKDIR /app
COPY . .
RUN mkdir dist
RUN ./build.sh
FROM nginx:1.23.1
COPY --from=build /app /usr/share/nginx/html
@sporsh
sporsh / index.html
Last active March 25, 2016 14:40
Astigmatism eye test (see live: https://goo.gl/TVVnVO)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Astigmatism eye test</title>
<style>
canvas {
position: fixed;
top: 0;
@sporsh
sporsh / _heightmap.png
Last active May 26, 2021 10:53
k-d tree / octree metaball https://goo.gl/km4snW
_heightmap.png

Keybase proof

I hereby claim:

  • I am sporsh on github.
  • I am sporsh (https://keybase.io/sporsh) on keybase.
  • I have a public key whose fingerprint is 2657 83C9 C0CD A7D3 00FA 9114 8A18 E5D2 F087 D6B5

To claim this, I am signing this object:

@sporsh
sporsh / app.yaml
Last active August 9, 2016 11:11
go raytracer
application: soft3dge
version: 0
runtime: go
api_version: go1
handlers:
- url: /
script: _go_app
@sporsh
sporsh / git-changes
Last active December 28, 2019 19:57
put this somewhere in your $PATH and run `git changes` in a repo to show differences in your local commits and upstream
#!/bin/bash
# Execute git fetch
git fetch &
# Get the pid of the `git fetch` process
pid=$!
# Characters used for the spinner animation
spin='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
@sporsh
sporsh / packet-adb.c
Created April 19, 2013 17:26
Android Debug Bridge (ADB) dissector for Wireshark
/*
* packet-adb.c
*
* Routines for Android Debug Bridge (ADB) protocol dissection
* Author: Geir Sporsheim <[email protected]>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
from twisted.internet.protocol import Protocol
import re
class ShellProtocol(Protocol):
"""Define a generic shell-like protocol:
[login-prompt [input-echo]]
[password-prompt] [input-echo]]
[greeting]
[prompt]
[input-echo]
@sporsh
sporsh / cache.py
Last active September 20, 2022 04:46
Python examples of proxy objects python -u cache.py
class CacheCallable(object):
"""Callable that cache results based on given arguments
"""
def __init__(self, func):
self.func = func
self.cache = {}
def __call__(self, *args):
try:
return self.cache[args]
@sporsh
sporsh / parse.py
Created November 22, 2012 00:17
Implementation of Android Debug Bridge (ADB) protocol in Twisted
from adb import protocol
data = (
'\x4f\x50\x45\x4e\x02\x00\x00\x00'
'\x00\x00\x00\x00\x09\x00\x00\x00'
'\x31\x03\x00\x00\xb0\xaf\xba\xb1'
'\x73\x68\x65\x6c\x6c\x3a\x6c\x73'
'\x00'
)