Skip to content

Instantly share code, notes, and snippets.

function convert(msg) {
var result = document.getElementById('message');
result.innerText = '$' + msg.formatMoney(2);
}
@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;
@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 / 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'
#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;
}
DEFAULT="[0m" #"[37;40m"
PINK="[35m"
GREEN="[32m"
ORANGE="[33m"
scm_branch() {
HG_BRANCH=`hg branch 2> /dev/null`
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD 2> /dev/null`
if [ -n "$HG_BRANCH" ]; then
<!doctype html>
<html>
<body>
<template id="name-tag">
<style>
div.container {
background: red;
padding: 0.5em;
border-radius: 1em;
width: 300px;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<template id="weather-info">
<style>
:host {
<!doctype html>
<html>
<body>
<button is="plastic-button">Click Me!</button>
<script>
class PlasticButton extends HTMLButtonElement {
constructor() {
super()
@AVGP
AVGP / append-to-dom.html
Last active February 14, 2017 14:57
Measuring speed of operations that append to DOM
<!doctype html>
<html>
<body>
<div id="target"></div>
<template>
<ul>
<li><a>Item #0</a></li>
<li><a>Item #1</a></li>
<li><a>Item #2</a></li>
<li><a>Item #3</a></li>