Skip to content

Instantly share code, notes, and snippets.

@jacktandrew
jacktandrew / Functions
Created December 8, 2012 01:00
Read More or Less
var textHolder = document.querySelector('.textHolder');
var fullText = textHolder.innerText;
var snippet = fullText.slice(0, 1000) + "...";
function createLink(quantity) {
var link = document.createElement("a");
link['href'] = "#";
link.className = quantity
link.innerText = "Read " + quantity;
textHolder.appendChild(link);
@jacktandrew
jacktandrew / Editable Content.js
Created November 2, 2012 14:57
html5 Summary part 2
function waitTilLoad(){
var editable = document.querySelector('.editable');
var reset = document.querySelector('.reset');
function blurring() {
localStorage.setItem('editedContent', this.innerHTML);
document.designMode = 'off';
}
function focusing() {
@jacktandrew
jacktandrew / Arrows
Created November 1, 2012 00:51
Loading Spinners
<html>
<head>
<style>
.arrow_wrap {
display: inline-block;
position: relative;
height: 54px;
width: 54px;
}
@jacktandrew
jacktandrew / Audio Video
Created October 19, 2012 04:53
html5 Summary
<h3>Dramatic Chipmunk</h3>
<video controls preload width=400px height=300px>
<source src="dramatic_chipmunk.ogv" type="video/ogg">
<source src="dramatic_chipmunk.mp4" type="video/mpeg">
You do not have HTML5 Video support.
</video>
<h3>Inconceivable</h3>
<audio controls>
<source src="thatword.ogg" type="audio/ogg">
$ ->
boneyard = []
boneBuilder = (a, b) -> # A set of dominos is contains every combination of possible with 6 - 0
boneyard.push('_' + a + '_' + b) # This recursive function push the two parameters into the boneyard array
return boneyard if b is 0 # If the 'b' variable is zero the loop is broken and the array is returned
(a = b; b--) if a is 0 # If 'a' is zero the value of 'b' is reduced by 1 and 'a' is set to the value of 'b'
boneBuilder(a-1, b) # Each iteration the value of 'a' is reduced by 1 and the function is called again
draw = (n) -> # This function picks dominos from the boneyard array
@jacktandrew
jacktandrew / gist:2314006
Created April 5, 2012 20:45
Dominoes w/ CoffeeScript
boneyard = []
boneBuilder = (a,b) ->
boneyard.push('_' + a + '_' + b)
return boneyard if b is 0
(a = b; b--) if a is 0
boneBuilder(a-1,b)
draw = (n) ->
randomDraw = _.shuffle(boneyard).splice(0, n)
fabricate value for value in randomDraw
@jacktandrew
jacktandrew / gist:2132556
Created March 20, 2012 07:38
Dominoes with Recursion
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/lib/underscore.js"></script>
<script src="js/lib/simple-inheritance.js"></script>
<script src="js/lib/backbone.js"></script>
<script src="js/lib/jStorage.js"></script>
<style>
div.tile {height: 70px; width: 35px; border-radius: 7px; float: left; margin: 10px;}
div.tile, div.bar {border: 2px outset #444;}
@jacktandrew
jacktandrew / gist:2131145
Created March 20, 2012 03:58
Create Dominoes
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<style>
div.tile {height: 70px; width: 35px; border-radius: 7px; float: left; margin: 10px;}
div.tile, div.bar {border: 2px outset #444;}
div.pips {height: 30px; width: 35px;position: relative; margin-top: 2px;}
div.pips div {border-radius: 5px; height: 4px; width: 5px; background: #333; position: absolute; border:2px inset #444;}