Skip to content

Instantly share code, notes, and snippets.

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

Luke Hedger lukehedger

🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)
View GitHub Profile
@lukehedger
lukehedger / browserBorder.css
Created January 22, 2014 14:56
Border around browser viewport - with scrollbars inside
.page-wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 700; /* must be the higher than all other elements */
overflow: auto; /* moves scrollbars inside border */
background: #fff;
border: 5px solid #ff9900;
@lukehedger
lukehedger / gWebFont.css
Last active August 14, 2023 13:36
Stylus + Google Web Fonts
/* Here's the compiled CSS */
@import url("http://fonts.googleapis.com/css?family=Droid+Sans");
body {
font-family: Droid Sans, Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 25px;
font-weight: 300;
color: #444;
}
@lukehedger
lukehedger / showHiddenFiles
Created January 6, 2014 15:35
Show hidden files on Mac OSX
# show
$ defaults write com.apple.finder AppleShowAllFiles TRUE
$ killall Finder
# hide
$ defaults write com.apple.finder AppleShowAllFiles FALSE
@lukehedger
lukehedger / bouncer.css
Created January 6, 2014 10:50
Bouncing text - with webkit prefixes, add others as required.
.bouncer {
display: inline-block;
-webkit-animation: bouncing 1s ease-in-out infinite;
-webkit-transform-origin: 50% 50%;
}
@-webkit-keyframes bouncing {
0% {
-webkit-transform: translateY(-3px);
}
25% {
@lukehedger
lukehedger / leadingZero.js
Created January 2, 2014 10:49
Add leading zeros (to months etc)
now = Date.now()
date = new Date(now)
m = ('0'+(date.getMonth()+1)).slice(-2) // add leading zero to month
@lukehedger
lukehedger / regExp.js
Last active December 31, 2015 15:29
RegExp collection
// basics
l = /^text$/, // literal notation
c = new RegExp("^text$"), // constructor notation
ltest = l.test(str), // test for expression, evaluates to true or false
ctest = c.test(str); // same test for both notations
// matching strings
var str = "this is a test";
@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
@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 / 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 / arraySort.coffee
Created November 11, 2013 11:28
CoffeeScript Array.sort
array = [
{
"id":"1",
"type":"z"
},
{
"id":"2",
"type":"a"
}
]