Skip to content

Instantly share code, notes, and snippets.

View cryptixcoder's full-sized avatar

Markus Gray cryptixcoder

View GitHub Profile
@cryptixcoder
cryptixcoder / gist:f2586dce299c1a1c9be2
Created June 10, 2015 19:41
Modal Checkout with stripe
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Modal Checkout - POC</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
$(document).on('click','.trackit', function(){
var action = $(this).data('ga-action'),
label = $(this).data('ga-label'),
category = $(this).data('ga-category');
ga('send','event',category,action,label);
});
@cryptixcoder
cryptixcoder / gist:9be38871fde03f4bf403
Created July 10, 2015 12:32
Paypal Currency and format array
$currencies = array(
'AUD' => array(
'label' => 'Australian Dollar',
'format' => '$ %s',
),
'CAD' => array(
'label' => 'Canadian Dollar',
'format' => '$ %s',
),
'EUR' => array(
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update

Laravel: drag-and-drop repositioning with auto-save of DB entries

Use case: Database entries are represented in a table. By grabbing and moving a row up or down the table, you can change the entries' order/position. The changes are submitted automatically via ajax.

  • Uses jQueryUI (custom download: sortable is needed)
  • newly created elements are added to the top (see route /jobs/create)

#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

$('.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;
@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() {
@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();
}
?>
User-agent: *
Disallow: /