Skip to content

Instantly share code, notes, and snippets.

View cryptixcoder's full-sized avatar

Markus Gray cryptixcoder

View GitHub Profile
@cryptixcoder
cryptixcoder / base64.js
Created April 24, 2016 17:56 — forked from whatnickcodes/base64.js
How to Encode and Decode Strings with Base64 in JavaScript
// Create Base64 Object
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r
@cryptixcoder
cryptixcoder / basic-auth.swift
Created February 6, 2016 00:26 — forked from armstrongnate/basic-auth.swift
HTTP Basic Authentication using NSURLSession in swift
import Foundation
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let userPasswordString = "username@gmail.com:password"
let userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding)
let base64EncodedCredential = userPasswordData!.base64EncodedStringWithOptions(nil)
let authString = "Basic \(base64EncodedCredential)"
config.HTTPAdditionalHeaders = ["Authorization" : authString]
let session = NSURLSession(configuration: config)
@cryptixcoder
cryptixcoder / ffmpeg.sh
Created January 13, 2016 20:51 — forked from erikccoder/ffmpeg.sh
ffmpeg to html5 video.
http://johndyer.name/ffmpeg-settings-for-html5-codecs-h264mp4-theoraogg-vp8webm/
REM mp4 (H.264 / ACC)
ffmpeg -i %1 -b 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 -s 640x360 %1.mp4
REM webm (VP8 / Vorbis)
ffmpeg -i %1 -b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30 -s 640x360 %1.webm
REM ogv (Theora / Vorbis)
ffmpeg -i %1 -b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30 -s 640x360 %1.ogv
REM jpeg (screenshot at 10 seconds)
ffmpeg -i %1 -ss 00:10 -vframes 1 -r 1 -s 640x360 -f image2 %1.jpg
@cryptixcoder
cryptixcoder / gist:513c69f5a69ab9e4c058
Created December 13, 2015 14:16
Command to get json output from ffprobe
ffprobe -v quiet -print_format json -show_format -show_streams somefile.asf
@cryptixcoder
cryptixcoder / gist:9a2c3c1f453d5011654e
Created December 2, 2015 21:26
duration of a video
$ffmpeg_output = shell_exec("ffmpeg -i \"$file\" 2>&1");
if( preg_match('/.*Duration: ([0-9:]+).*/', $ffmpeg_output, $matches) ) {
echo $matches[1];
} else {
echo "$file failed\n";
}
User-agent: *
Disallow: /
@cryptixcoder
cryptixcoder / gist:4428af58e1c2b2d1d58c
Created September 8, 2015 20:46
Generate Order Number
<?php
function gen_order_num(){
return substr(md5(microtime()), rand(0,26),3).time();
}
?>
@cryptixcoder
cryptixcoder / gist:c48d61535afb8f325da8
Created September 2, 2015 13:19
Hide/Show Nav on scroll
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('nav').outerHeight();
$(window).scroll(function(event){
didScroll = true;
});
setInterval(function() {
$('.checkout').submit(function(e){
e.preventDefault();
var stripeKey = $('meta[name=stripe-publishable-key]').attr('content');
var form = $(this);
form.find('button').prop('disabled', true);
var number = form.find('#ccnumber').val();
var securitycode = form.find('#securitycode').val();
var exp = form.find('#expdate').val().split;

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.

Installation

Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php