JSFiddle

  • VectorBlend

    An experiment in canvas vector fields

    // canvas basics
    var c = document.getElementById('canvas');
    var ctx = c.getContext('2d');
    
    // twiddle factors:
    var speedScale = 0.05; // affects speed ...
  • Tiny sqrt

    Nothing clever

    
    
    function s(x){for(t=x/2,a=1,b=x,i=0;i++<32;t=a+(b-a)/2)t*t-x>0?b=t:(a=t);return ...</32;t=a+(b-a)/2)t*t-x>
  • Salsa20

    From https://gist.github.com/dchest/4126510

    // Note: this is for scrypt implementation, which doesn't use diagonal constants, 
    // so the order of loading from x is ...
  • simple encoding

    No-Library (pure JS), HTML, CSS, JavaScript

    // just for play
    
    var codeStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234789!*&@#";
    
    function make() {
    	var iter  = parseInt(document.getElementById("iter").value);
    	var base  = document.getElementById("base ...
  • BWT

    Burrows Wheeler Transform

    
    // this is the inefficient 'table building' way
    function BWT (str) {
      var data = str.split('');
      var len = data.length;
      var index ...
  • JavaScript: base64 encode and decode

    No-Library (pure JS), HTML, CSS, JavaScript

    var Base64 = {
    
    
        _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
    
    
        encode: function(input) {
            var output = "";
            var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
            var i = 0 ...
  • SpeechSynth #47 is the latest revision

    for play

    /*
    
    Simple formant speech synth.
    
    Based on http://heckmeck.de/demoscene/tiny-speech-synth-js/ (credits at bottom)
    Similar to the one at https ...
  • Day on date algorithm

    No-Library (pure JS), HTML, CSS, JavaScript

    var DayOfWeek=[
    	"Sunday",
    	"Monday",
    	"Tuesday",
    	"Wednesday",
    	"Thursday",
    	"Friday",
    	"Saturday"
    ]
    
    function GetDayOfWeek(year, month, day)
    {
    	var monthAdjust = [ 0, 3, 2, 5 ...
  • Starwars sketch #5 is the latest revision

    Webkit perspective demo

    var sp = document.getElementById('scroll');
    setInterval(function(){ sp.scrollTop++; }, 100);
    
  • JS truthy table

    example of javascript behaviour

    var cmp = function(v1, v2) { return v1 == v2; };
    var vals = [
        ["false", function() { return false; }], 
        ["0", function() { return 0; }],
        ['""', function() { return ...