Skip to content

Instantly share code, notes, and snippets.

@n1ckfg
n1ckfg / Encoding.pde
Created January 25, 2018 19:44
Bit wrangling methods for Processing
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import java.util.Base64;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
float getVFov(float hFov, float w, float h) {
float hFovRad = hFov * PI / 180;
float vFovRad = 2 * atan(tan(hFovRad/2) * h/w);
return ceil(vFovRad * 180 / PI);
}
void setup() {
println("horizontal FOV 90 -> " + getVFov(90, 16, 9) + " vertical FOV (16:9)");
}
// https://forums.oculusvr.com/community/discussion/57052/quill-fbx-to-unity3d#latest
Shader "Unlit/Quill Shader" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
>>> gps()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in gps
File "/home/nick/GitHub/ros_unreal/tools/AirSimClient/AirSimClient.py", line 563, in getGpsLocation
return GeoPoint.from_msgpack(self.client.call('getGpsLocation'))
File "/home/nick/.local/lib/python3.5/site-packages/msgpackrpc/session.py", line 41, in call
return self.send_request(method, args).get()
File "/home/nick/.local/lib/python3.5/site-packages/msgpackrpc/future.py", line 45, in get
raise error.RPCError(self._error)
@n1ckfg
n1ckfg / index.html
Created March 7, 2018 14:51
Fullscreen iframe
<!DOCTYPE html>
<html>
<head>
<style>
body {
background: black;
margin: 0px;
}
@n1ckfg
n1ckfg / ae_counter.js
Created March 19, 2018 01:14
AE counter expression formatted with commas
var val = "" + Math.round(effect("Point Control")("Point")[0]);
var returns = "";
for (var i=val.length-1; i>=0; i--) {
returns += val[Math.abs(val.length-1-i)];
if (i!=0 && i%3 == 0) returns += ",";
}
returns;
#def writeSvg(strokes=None, name="test.svg", minLineWidth=3, camera=None):
#def writeSvg(filepath=None, minLineWidth=3, camera=None, fps=12, start=0, end=73):
def writeSvg(filepath=None):
minLineWidth=3
camera=None
fps=None
start=None
end=None
#~
#if not strokes:
@n1ckfg
n1ckfg / ObjExportTest.pde
Created April 4, 2018 21:39
example using nervoussystem ObjExport
import nervoussystem.obj.*;
PImage img;
boolean record = false;
void setup() {
size(600, 400, P3D);
img = loadImage("fox.png");
img.loadPixels();
noStroke();
@n1ckfg
n1ckfg / zip_test.py
Last active April 20, 2018 02:40
Read and write a zip file in memory using Python
# https://stackoverflow.com/questions/10908877/extracting-a-zipfile-to-memory
# https://stackoverflow.com/questions/11914472/stringio-in-python3
# https://docs.python.org/2/library/zipfile.html
import zipfile
from io import BytesIO
class InMemoryZip(object):
def __init__(self):