Skip to content

Instantly share code, notes, and snippets.

// Generit list of fruits. Using this method of “for”, an object would not work
var fruits = ['mango', 'grapes', 'lemon', 'grapefruit', 'melon'];
(function () {
"use strict";
// Setup the i variable within the current function
var i, li, body,
// Set the fruit list dom element via ID since class would imply more than 1
@HTMLToronto
HTMLToronto / #StreamingSunday 2012-03-24 Overblown randomization script
Created March 25, 2013 00:56
Sample randomization script. Please note that this is not something you should use in your production code. The randomization here is by far not the most efficient manner to randomize something. It is intended to demonstrate an extreme.
/*
* Create a shuffle array method returning the new shuffled array instead of effecting the original
*/
Array.prototype.shuffle = function () {
for (var i = this.length - 1; i > 0; i--) {
var randomIndex = Math.floor(Math.random() * (i + 1));
var tmp = this[i];
this[i] = this[randomIndex];
this[randomIndex] = tmp;
}
@HTMLToronto
HTMLToronto / WebRTC Minimal Example
Created February 25, 2013 01:32
WebRTC minimal example for you to start playing with. Post your results back to @HTML5_Toronto and show off your skills. Remember, if you’re using Firefox, the current version requires you to activate the media.peerconnection.enabled within the about:config setting.
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<video></video>
<script>
window.addEventListener('DOMContentLoaded', function() {
'use strict';