Skip to content

Instantly share code, notes, and snippets.

View lukehedger's full-sized avatar
🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)

Luke Hedger lukehedger

🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)
View GitHub Profile
@lukehedger
lukehedger / absoluteValues.xsl
Created July 3, 2012 15:18
XSL - Format numbers as absolute values
<!-- Formatting a number with '#.##;#.##' will return the absolute value -->
<xsl:variable name="absoluteValue" select="format-number($originalValue,'#.##;#.##')"/>
@lukehedger
lukehedger / showFeed.xml
Created July 3, 2012 15:26
XML - Show full feed on page
<!-- Textarea can be resized as required. Its just used to contain the feed -->
<textarea cols='150' rows='30'><xsl:copy-of select='/'/></textarea>
@lukehedger
lukehedger / Slidershow.js
Created July 25, 2012 09:42
JS - Use the jQuery Slider control to create an interactive slideshow
//master function to hold all actions on slider
//HTML - you'll need an empty div with id=slider to hold the initiated control
$(function() {
$( "#slider" ).slider({
value:1, //start pos
min: 1,
max: 7, //number of slides
step: 1,
animate: true,
change: function( event, ui ) { //run function each time the slider is used
info: Creating snapshot 0.0.1-1
info Uploading: [=============================] 100%
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
help: For help with this error contact Nodejitsu Support:
help: webchat: <http://webchat.nodejitsu.com/>
help: irc: <irc://chat.freenode.net/#nodejitsu>
help: email: <support@nodejitsu.com>
help:
help: Copy and paste this output to a gist (http://gist.github.com/)
@lukehedger
lukehedger / arrayFilter.coffee
Last active December 27, 2015 11:59
CoffeeScript Array.filter
array = [
{
"id":"1",
"type":"a"
},
{
"id":"2",
"type":"b"
}
]
@lukehedger
lukehedger / randomNumber.coffee
Last active July 17, 2016 03:17
CoffeeScript random number generator
_randomNum: (max,min=0) ->
return Math.floor(Math.random() * (max - min) + min)
# min is set to 0 by default but a different value can be passed to function
_randomise: ->
randomNum = @_randomNum(10)
# returns a random integer between 0 and 10
@lukehedger
lukehedger / arraySort.coffee
Created November 11, 2013 11:28
CoffeeScript Array.sort
array = [
{
"id":"1",
"type":"z"
},
{
"id":"2",
"type":"a"
}
]
@lukehedger
lukehedger / iframeCheck.coffee
Last active December 30, 2015 21:29
Check for parent window/iframe
# check if page loaded within iframe
if window.parent != window
console.log 'within iframe'
# access properties from the parent window object
orientation = window.parent.orientation
else
console.log 'no iframe'
# access properties from the window object as normal
orientation = window.orientation
@lukehedger
lukehedger / MinMax.coffee
Created December 10, 2013 10:32
MinMax helper class in CoffeeScript
class MinMax
@min: (array) -> Math.min.apply Math, array
@max: (array) -> Math.max.apply Math, array
# Use...
min = MinMax.min [0,1,2]
max = MinMax.max [5,4,3]
@lukehedger
lukehedger / scrollTo.coffee
Created December 17, 2013 15:01
Animated ScrollTo element
_addListeners: ->
$(document).on 'click', '.scrollTo', @_onScrollToClick
# where <a id="#element"> corresponds to <div id="element">
_onScrollToClick: ->
id = $(this).attr 'id'
$('html,body').animate {scrollTop: $(id).offset().top},400