Skip to content

Instantly share code, notes, and snippets.

@djmadeira
djmadeira / index.js
Last active April 6, 2022 20:57
"An Introduction to WebGL" tutorial code in vanilla JS
// From http://robots.thoughtbot.com/an-introduction-to-webgl
var app = function () {
var canvas = document.getElementById('canvas'),
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
// Create elements on the page which contain your shaders.
// I like using script tags with a different type attribute, like:
// `<script id="vertex-shader" type="x-vertex/x-shader">`
// You could also just put the shaders inline, but I hate escaping line breaks.
var shaders = {
@djmadeira
djmadeira / gist:8b9d825ca98ed9997914
Created June 16, 2015 15:37
Simple countdown timer in JS
/**
* Don't put your vars in the global scope in production code,
* much less these tersely-named ones.
*/
var end = new Date('July 1, 2016 12:00:00');
var el;
// Seconds/minute, etc (in miliseconds)
@djmadeira
djmadeira / test-destructuring-safe.js
Last active March 16, 2017 14:33
lodash.get vs destructuring wrapped in try catch vs unsafe destructuring (node 6.9.4)
'use strict';
const lodash = require('lodash');
function getObj() {
return {
prop1: {
0: { },
1: null,
2: {
@djmadeira
djmadeira / app.js
Created August 11, 2017 03:07
@std/esm issue demo
import src from './src';
console.log(src({ apple: 'hi' }));