Skip to content

Instantly share code, notes, and snippets.

View sdeering's full-sized avatar

Sam Deering sdeering

View GitHub Profile
@sdeering
sdeering / gist:7459482
Created November 14, 2013 01:07
URL Params
/*
http://www.jquery4u.com/snippets/url-parameters-jquery/
*/
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
@sdeering
sdeering / gist:7459478
Created November 14, 2013 01:06
Capture iPad device change (IOS7) tested.
//capture ipad device change (IOS7) tested.
function doOnOrientationChange()
{
// alert(window.orientation);
switch(window.orientation)
{
case 0:
case 90:
// alert('portrait');
$('html').removeClass('landscape').addClass('portrait');
@sdeering
sdeering / gist:7153714
Last active December 26, 2015 12:49
Basic Node.js Crypto Cipher Encryption Example
var cryptojs = require('crypto')
, salt = "<client app salt token>"
, keyIterations = 1000 //number of interations to generate your key
, keyLength
, key
, password
, cipher
, msg = "<what you want to encrypt>"
, encryptedMsg;
@sdeering
sdeering / gist:4356baed3692d26ab778
Created August 11, 2014 15:14
injectorsauce with meta tag check
/**
* CSRF Token Security.
*/
(function() {
angular.module("app").config(['$httpProvider', function ($httpProvider) {
//check for token in meta tag
var csrf_token = $('meta[name=csrf-token]').attr('content');
@sdeering
sdeering / .htaccess
Created August 11, 2014 03:33
Laravel 4 with AngularJS Architecture Solution .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect root requests
RewriteCond %{REQUEST_URI} ^/$
RewriteRule !^/ /back-end/public%{REQUEST_URI} [L]
@sdeering
sdeering / gist:11131879
Created April 21, 2014 04:01
node.js xhr with promises using q library
function _functionName(url) {
return Q.fcall(function () {
var deferred = Q.defer();
var options = {
url: url,
headers: {
'User-Agent': 'my-app'
},