Skip to content

Instantly share code, notes, and snippets.

@A
Last active August 29, 2015 14:00

Revisions

  1. A renamed this gist May 19, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. A revised this gist Apr 24, 2014. 4 changed files with 3 additions and 27 deletions.
    4 changes: 3 additions & 1 deletion dabblet.js → bogosort.js
    Original file line number Diff line number Diff line change
    @@ -20,4 +20,6 @@ var bogosort = function (arr) {
    shuffle(arr);
    i++;
    }
    };
    };

    bogosort([2,1,3,4,6,5,7,8,9,10])
    21 changes: 0 additions & 21 deletions dabblet.css
    Original file line number Diff line number Diff line change
    @@ -1,21 +0,0 @@
    /**
    * The first commented line is your dabblet’s title
    */

    .a {
    width: 600px;
    height: 400px;
    background-color: #eba;
    position: relative;
    }

    .b {
    background: #bae;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 200px;
    margin: auto;
    }
    4 changes: 0 additions & 4 deletions dabblet.html
    Original file line number Diff line number Diff line change
    @@ -1,4 +0,0 @@
    <!-- content to be placed inside <body>…</body> -->
    <div class="a">
    <div class="b"></div>
    </div>
    1 change: 0 additions & 1 deletion settings.json
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    {"view":"separate","fontsize":"80","seethrough":"","prefixfree":"1","page":"javascript"}
  3. A created this gist Apr 24, 2014.
    21 changes: 21 additions & 0 deletions dabblet.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    /**
    * The first commented line is your dabblet’s title
    */

    .a {
    width: 600px;
    height: 400px;
    background-color: #eba;
    position: relative;
    }

    .b {
    background: #bae;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 200px;
    margin: auto;
    }
    4 changes: 4 additions & 0 deletions dabblet.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    <!-- content to be placed inside <body>…</body> -->
    <div class="a">
    <div class="b"></div>
    </div>
    23 changes: 23 additions & 0 deletions dabblet.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    var isSorted = function (arr) {
    for (var i in arr) {
    if (i === 1) next;
    if (arr[i-1] > arr[i]) return false;
    }
    return true;
    };


    var shuffle = function (arr) {
    return arr.sort(function() {
    return .5 - Math.random();
    });
    };


    var bogosort = function (arr) {
    var i = 0;
    while (!isSorted(arr)) {
    shuffle(arr);
    i++;
    }
    };
    1 change: 1 addition & 0 deletions settings.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    {"view":"separate","fontsize":"80","seethrough":"","prefixfree":"1","page":"javascript"}