Skip to content

Instantly share code, notes, and snippets.

Avatar
🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)

Luke Hedger lukehedger

🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)
View GitHub Profile
@lukehedger
lukehedger / law-permissions.sh
Created Aug 27, 2015
Nail permissions on Law
View law-permissions.sh
$ ll
$ sudo chown -R hub_bot:www-data .
$ sudo chmod -R 755 .
@lukehedger
lukehedger / convertRoundMiles.coffee
Created Feb 18, 2014
Convert KM to Miles and round to 1 dp
View convertRoundMiles.coffee
distanceKM = 100
distanceMiles = distanceKM / 0.6 # => 166.66667
distanceMilesRounded = parseFloat(distanceMiles, 10).toFixed 1 # => 166.7
@lukehedger
lukehedger / requireNonAMD.js
Created Feb 18, 2014
RequireJS with non-AMD modules
View requireNonAMD.js
// 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 / setTimeout.coffee
Created Feb 27, 2014
CoffeeScript setTimeout
View setTimeout.coffee
setTimeout =>
@_delayedFunc()
,1000
@lukehedger
lukehedger / obj.php
Created Mar 20, 2014
Quick object in PHP
View obj.php
$obj = (object) array('prop' => value, 'prop' => $var);
@lukehedger
lukehedger / textOverflow.css
Created Mar 28, 2014
Text overflow ellipsis
View textOverflow.css
.overflowing-text {
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
View FlashDetect.coffee
detectFlash: ->
if navigator.plugins["Shockwave Flash"]
return true
return false
# usage:
# if detectFlash()
# console.log "Flash supported"
# else
@lukehedger
lukehedger / htaccess-extension-remover
Created Jun 5, 2014
Remove URL file extensions using .htaccess
View htaccess-extension-remover
# ----------------------------------------------
# Quick method:
# ----------------------------------------------
Options +MultiViews
# With Apache MultiViews, the server will look for files that match the requested resource (eg. a request for "site.com/page" will serve "site.com/page.php")
# ----------------------------------------------
# Long method:
@lukehedger
lukehedger / OO.js
Created Jun 24, 2014
Skeleton object-orientated JS
View OO.js
var app = new App('arg');
App = function(arg) {
this.APP_CONSTANT = 0;
this.appVar = arg;
this._init();
}
@lukehedger
lukehedger / pythonServer.bash
Created Jun 27, 2014
Python SimpleHTTPServer
View pythonServer.bash
$ python -m SimpleHTTPServer 8000