Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
char utf8[4] = {'\xe2', '\x80', '\xa6', '\x00'}; // first three bytes are the "..." UTF-8 character, fourth byte is string termination
int main ()
{
std::cout << utf8 << std::endl;
return 0;
}
@AVGP
AVGP / undefined-behaviour.html
Created October 17, 2016 13:37
Demonstrates the issue with switching between different WebVR content within the same page
<html>
<body>
<button id="first">First Demo</button>
<button id="second">Second Demo</button>
<iframe width="500" height="500" src="03-vr-presentation.html" allowvr></iframe>
<script>
var iframe = document.querySelector('iframe')
document.getElementById('first').addEventListener('click', function() {
iframe.contentWindow.location.href = '03-vr-presentation.html'
@AVGP
AVGP / canvas2d.html
Created June 8, 2016 20:17
Comparison: Repeat & scale image -- Canvas 2D vs. WebGL
<!doctype html>
<html>
<head>
</head>
<body>
<canvas width="1920" height="1080"></canvas>
<script>
var frameCount = 0, fps = 0, tStart = 0
var ctx = document.querySelector('canvas').getContext('2d')
@AVGP
AVGP / shaderpad-snippets.md
Created April 17, 2016 17:37
A few nice shader snippets for Shaderpad

Basics

simple red horizontal gradient

precision highp float;
varying highp vec2 vTextureCoord;

uniform sampler2D uSampler;
function convert(msg) {
var result = document.getElementById('message');
result.innerText = '$' + msg.formatMoney(2);
}
@AVGP
AVGP / index.html
Last active September 28, 2017 02:49
Example of using Three.js, the SoftwareRenderer
<!doctype html>
<html>
<head>
<title>Isomorphic Three.js</title>
<style>
html, body {
height: 100%;
height: 100vh;
padding: 0;
@AVGP
AVGP / make-animated-gif.js
Last active August 9, 2023 00:18
Uses three.js, three-software-renderer & omggif to render an animated GIF from a Three.js Scene on the server with node.js
var fs = require('fs'),
omggif = require('omggif'),
THREE = require('three'),
SoftwareRenderer = require('three-software-renderer');
// How many frames and how large shall the GIF be?
var NUM_FRAMES = 200, WIDTH = 500, HEIGHT = 500;
// Our scene, camera and renderer and a box to render
var scene = new THREE.Scene(),
[2015-09-08 14:56:17,530][WARN ][transport.netty ] [Captain Wings] exception caught on transport layer [[id: 0x93369774, /127.0.0.1:37573 :> /127.0.0.1:9300]], closing connection
java.io.StreamCorruptedException: invalid internal transport message format
@AVGP
AVGP / hg_changes.bash
Created August 10, 2015 18:58
Small bash function that outputs the number of lines added and removed in a commit
DEFAULT="[37;40m"
RED="[31;40m"
GREEN="[32;40m"
hg_changes() {
echo -e "\e${RED}`hg log -pr $1 | grep '^+' | wc -l` Additions\e${DEFAULT}"; echo -e "\e${GREEN}`hg log -pr $1 | grep '^-' | wc -l` Deletions\e${DEFAULT}";
}
@AVGP
AVGP / presentation.py
Created June 26, 2015 06:03
Python script to listen to Myo "WAVE" poses to send left/right key events under Linux
import sys
import os
sys.path.append('../lib/')
from device_listener import DeviceListener
from pose_type import PoseType
class WavePoseListener(DeviceListener):
def on_pose(self, pose):
pose_type = PoseType(pose)