Skip to content

Instantly share code, notes, and snippets.

View kyleridolfo's full-sized avatar

Kyle Ridolfo kyleridolfo

View GitHub Profile
@kyleridolfo
kyleridolfo / springer-free-maths-books.md
Created December 28, 2015 20:44 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
@kyleridolfo
kyleridolfo / README.md
Created September 30, 2015 19:53
Secure Middleware for Laravel 5

I noticed that Laravel 5 doesn't have a secure (https) middleware since the removal of filters. So i have re-implemented it and shared the code in the hope that you find it useful.

Installation

  • Add Secure.php to your app\Http\Middleware directory.
  • Add the secure middleware to your route.

Notes

  • If you are using route annotations, don't forget to re-scan your routes using the php artisan route:scan command.
@kyleridolfo
kyleridolfo / ga-video.js
Created September 3, 2015 18:41
HTML5 Video Tracking for Google Tag Manager
<script>
// Let's wrap everything inside a function so variables are not defined as globals
(function(){
// This is gonna our percent buckets ( 10%-90% )
var divisor = 10;
// We're going to save our players status on this object.
var videos_status = {};
// This is the funcion that is gonna handle the event sent by the player listeners
function eventHandler(e){
switch(e.type) {
@kyleridolfo
kyleridolfo / getviewport.js
Created June 26, 2015 17:40
Get browser viewport
function getViewport() {
var viewPortWidth;
var viewPortHeight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') {
viewPortWidth = window.innerWidth,
viewPortHeight = window.innerHeight
}
$(function() {
});
@kyleridolfo
kyleridolfo / .bash_profile
Created June 16, 2015 19:25
Open shortcut for bash
function o() {
currentDir='.'
open ${1-$currentDir}
}
@kyleridolfo
kyleridolfo / gist:b20e0bc144c4d9fd5b93
Created May 2, 2015 18:25
Parse list of filenames to move files
#/bin/bash
for F in $(cat ./filelist.txt) ; do
mv $F ./uploaded/
done;
@kyleridolfo
kyleridolfo / gist:845c59859e91a0620131
Created April 29, 2015 17:33
Random background colors
// assigns random background color to help with layout.
$(".target").each(function() {
var hue = 'rgb(' + (Math.floor((256-199)*Math.random()) + 200) + ',' + (Math.floor((256-199)*Math.random()) + 200) + ',' + (Math.floor((256-199)*Math.random()) + 200) + ')';
$(this).css("background-color", hue);
});
@kyleridolfo
kyleridolfo / uri.js
Last active August 29, 2015 14:18 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@kyleridolfo
kyleridolfo / gist:776d85e6328f13a8b72a
Created September 25, 2014 14:34
Password protect a URI
SetEnvIf Request_URI "/page-to-protect" passreq
AuthType Basic
AuthName "Password Required"
AuthUserFile /path/to/.htpasswd
Require valid-user
Order allow,deny
Allow from all
Deny from env=passreq
Satisfy any