Skip to content

Instantly share code, notes, and snippets.

View smayzes's full-sized avatar

Shawn Mayzes smayzes

View GitHub Profile
@smayzes
smayzes / gist:2aa5b737c7a44423c23e
Created July 2, 2014 06:13
Generate Card via Stripe.js
Check out http://www.shawnmayzes.com/code/php/stripe/stripe-api for more information.
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
jQuery(function($) {
$('form').submit(function(event) {
var $form = $(this);
$('input[type=submit]').prop('disabled', true); // Disable the submit button from being clicked multiple times
@smayzes
smayzes / jQuery Ajax
Last active August 29, 2015 14:05
jQuery Ajax
$.ajax({
type : 'post',
url : '<URL>',
data: {
data : $('something').val()
},
success : function(data) {
},
error : function(data) {
@smayzes
smayzes / Prevent Double clicking
Created August 11, 2014 17:07
Prevent Double clicking
// Via element properties
$('something').click(event) {
event.preventDefault();
// Disable this button
$(this).prop('disabled', true);
// Do something
...
@smayzes
smayzes / gist:c26ae6a2589357bb44a4
Last active August 29, 2015 14:24
Example Nginx Conf
# Redirect WWW to non-WWW
server {
listen 80;
server_name www.example.org;
return 301 $scheme://example.org;
}
# Non-WWW Block
server {
@smayzes
smayzes / uri.js
Last active August 29, 2015 14:27 — forked from jlong/uri.js
URI Parsing with Javascript
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"

PHP

'123abc' == 123 // True
'123abc' === 123 // False

echo true;		// 1
echo false;		// blank return
@smayzes
smayzes / ModelMakeCommand.php
Last active June 5, 2020 02:33
Laravel Model - Alter Folder Location for Artisan Make
<?php
namespace App\Console\Commands;
use Illuminate\Foundation\Console\ModelMakeCommand as Command;
class ModelMakeCommand extends Command
{
/**
* Get the default namespace for the class.
@smayzes
smayzes / gist:0eb0d3f02d6cfaefded4c1953989892a
Created March 22, 2018 15:43
Validate Route Param in routes file
$router->bind('username', function ($username) {
return User::whereUsername($username)->firstOrFail();
});
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateClinicTable extends Migration
{
/**
* Run the migrations.
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePatientsTable extends Migration
{
/**
* Run the migrations.