Skip to content

Instantly share code, notes, and snippets.

View MarkVaughn's full-sized avatar
🤡

Mark Vaughn MarkVaughn

🤡
View GitHub Profile
@MarkVaughn
MarkVaughn / get_set_url_param.js
Created March 19, 2012 05:29
Get & Set URL parameter in Javascript
function getURLParameter(name) {
return decodeURIComponent(
(RegExp('[?|&]'+name + '=' + '(.+?)(&|$)').exec(location.search)||[null,null])[1]
);
}
function setURLParameter(name,value){
var search;
if(getURLParameter(name)){
search =location.search.replace(new RegExp('([?|&]'+name + '=)' + '(.+?)(&|$)'),"$1"+encodeURIComponent(value)+"$3");
}else if(location.search.length){
@MarkVaughn
MarkVaughn / pagination.jade
Created September 25, 2012 08:54
jade pagination template
-// example pagination object
- var p = {current: 4, total: 10}
-// actual template
.paginationcontrol
- if(p.current > 1)
a.page.page-first(href=util.urlHelper({p:null})) <<
a.page.page-prev(href=util.urlHelper({p:(p.current - 1)!=1?(p.current - 1): null})) <
- else
span.page.disabled.page-first <<
span.page.disabled.page-prev <
@MarkVaughn
MarkVaughn / Reset form with jQuery
Last active December 13, 2015 21:08 — forked from dantoncancella/gist:4564386
Chaining reset function for jQuery, pass a function to bind on the reset event.
(function($){
$.fn.reset = function(fn) {
return fn ? this.bind("reset", fn) : this.trigger("reset");
};
})(jQuery);
@MarkVaughn
MarkVaughn / gist:f99c2b1f688cf6999c25
Created February 29, 2016 22:27
Delete all arcpatches
git branch | grep arcpatch | xargs git branch -D
@MarkVaughn
MarkVaughn / assertValid.php
Last active December 20, 2016 14:50
Assert Valid
/**
* Asserts a single value passes on one ore many laravel validation rules.
*
* @param array|string $rule
* @param mixed $value
*/
protected function assertValid($rule, $value)
{
$rules = [
General
# 2×× - Success
## 200 - OK
Hopefully most your responses
## 202 - Accepted
Used in [/post/api/v1/orders](API-Reference#post-apiv1orders) when the order needs to be confirmed via email verification.
[More](https://httpstatuses.com/202)
@MarkVaughn
MarkVaughn / random_image.php
Created April 12, 2018 18:29
Simple random image
<?php
function randomImage(int $width, int $height)
{
$image = imagecreatetruecolor($width, $height);
for($row = 1; $row <= $height; $row++) {
for($column = 1; $column <= $width; $column++) {
$red = mt_rand(0,255);
$green = mt_rand(0,255);
$blue = mt_rand(0,255);
$colour = imagecolorallocate ($image, $red , $green, $blue);
@MarkVaughn
MarkVaughn / pre-commit.lint
Last active June 27, 2018 17:59 — forked from mindbat/pre-commit.lint
Git pre-commit script to run all the modified files through php-lint. Won't let you commit php file with a syntax error.
#!/bin/sh
#
# Hook script to check the changed files with php lint
# Called by "git commit" with no arguments.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD