Skip to content

Instantly share code, notes, and snippets.

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

Luke Hedger lukehedger

🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / requireNonAMD.js
Created February 18, 2014 12:13
RequireJS with non-AMD modules
// 1. Add definition to foot of module.js (the required file)
// AMD Define
define(function(){
return baron;
});
// 2. Add the path to main.js (requireJS config) as normal
require.config({
baseUrl: "/sites/all/themes/base/js/",
@lukehedger
lukehedger / convertRoundMiles.coffee
Created February 18, 2014 17:39
Convert KM to Miles and round to 1 dp
distanceKM = 100
distanceMiles = distanceKM / 0.6 # => 166.66667
distanceMilesRounded = parseFloat(distanceMiles, 10).toFixed 1 # => 166.7
@lukehedger
lukehedger / setTimeout.coffee
Created February 27, 2014 10:10
CoffeeScript setTimeout
setTimeout =>
@_delayedFunc()
,1000
@lukehedger
lukehedger / obj.php
Created March 20, 2014 12:13
Quick object in PHP
$obj = (object) array('prop' => value, 'prop' => $var);