Skip to content

Instantly share code, notes, and snippets.

@thefrontender
thefrontender / hearts.js
Created April 15, 2012 23:37
Hearts card game in JS
/*
Timing and asynchronus events
http://javascript.info/tutorial/events-and-timing-depth
PubSubJS
https://github.com/mroderick/PubSubJS
http://jsperf.com/pubsubjs-vs-jquery-custom-events/6
http://maxpert.tumblr.com/post/2658433646/puny-standalone-javascript-custom-pubsub-events-library
http://higginsforpresident.net/js/static/jq.pubsub.js
@thefrontender
thefrontender / css-playing-cards.html
Created April 15, 2012 23:35
CSS playing cards
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Card test - 10K Hearts</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
@thefrontender
thefrontender / hideaddrbar.js
Created January 11, 2012 02:15 — forked from scottjehl/hideaddrbar.js
Normalized hide address bar for iOS & Android (JSLint compliant)
/*jslint browser: true, indent: 4 */
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function (win) {
'use strict';
var doc = win.document,
scrollTop = 1,
@thefrontender
thefrontender / HTML5-dictate
Created November 9, 2011 05:26
A quick dictation demo using new Speech, Blobs, Drag n Drog APIs from HTML5. Use latest version of Chrome.
<!doctype html>
<html>
<head>
<title>Dictation with HTML5 - Using Speech, Blobs, Drag & Drop APIs</title>
</head>
<body>
<input id="dictate" type="text" speech x-webkit-speech />
<textarea id="post"></textarea>
<a href="#" id="dragout" draggable="true">Save Text file (drag to desktop)</a>
<script>
@thefrontender
thefrontender / dealer.js
Created August 16, 2011 13:59
Javascript Dealer class for card games.
var Dealer = function (decks, suits, cards) {
var pack = [], // cards yet to be dealt (stock/shoe)
played = 0, // cards already dealt,
suitsLen,
cardsLen,
i,
j,
// Fisher-Yates shuffle - http://jsfromhell.com/array/shuffle