Skip to content

Instantly share code, notes, and snippets.

@jasonhinkle
jasonhinkle / gist:751a2760c73f7d507cc3
Created May 18, 2014 20:09
Add onFail event to BootstrapValidator
var validator = $('#myForm).data('bootstrapValidator');
var validatorPrototype = Object.getPrototypeOf(validator);
validatorPrototype._real_submit = validatorPrototype._submit;
validatorPrototype._submit = function(){
var r = this._real_submit();
if ((!this.isValid()) && 'function' == typeof(this.options.failHandler)){
this.options.failHandler.call(this);
}
return r;
};
@jasonhinkle
jasonhinkle / gist:069a770a3e9029cbfe24
Created May 19, 2014 07:11
bootstrapValidator form-level error container
<script>
$(document).ready(function(){
$('#myForm').bootstrapValidator({
container: '#form-errors',
fields: {
FieldOne: {
validators: {
notEmpty: { message: 'Please provide a value for Field One' }
}
},
<?php
$this->assign('title','CARGO | Packages');
$this->assign('nav','packages');
$this->display('_Header.tpl.php');
?>
<script type="text/javascript">
$LAB.script("scripts/app/packages.js").wait(function(){
$(document).ready(function(){
/**
* View logic for Packages
*/
/**
* application logic specific to the Package listing page
*/
var page = {
packages: new model.PackageCollection(),
@jasonhinkle
jasonhinkle / utils.php
Last active August 29, 2015 14:04
Imsanity custom Util.php for testing image rotation
<?php
/**
* ################################################################################
* UTILITIES - *** CUSTOM VERSION FOR TESTING ROTATION ***
* ################################################################################
*/
/**
* Util function returns an array value, if not defined then returns default instead.
* @param Array $array
@jasonhinkle
jasonhinkle / Branch Workflow.sh
Last active February 24, 2016 03:07
Branch Workflow
# INITIAL SETUP
# make sure you are working with the most recent code
git pull
# create branch & optionally add it to remote origin
git checkout -b <branchname>
git push -u origin <branchname>
# REGULAR WORKFLOW
@jasonhinkle
jasonhinkle / ajax.js
Last active February 20, 2023 17:42
jQuery AJAX Snippet
$.ajax({
url: 'api/url',
method: 'POST',
data: {var:'val'},
// data: JSON.stringify({var:'val'}), // send data in the request body
// contentType: "application/json; charset=utf-8", // if sending in the request body
dataType: 'json'
}).done(function(data, textStatus, jqXHR) {
// because dataType is json 'data' is guaranteed to be an object
console.log('done');
@jasonhinkle
jasonhinkle / phantom-hotfix.md
Last active August 29, 2015 14:27
Patching PhantomJS 2.0

The PhantomJS 2.0 official binary has problems when using with Selenium. Pre-built hotpatched versions of phantomjs for OSX and Ubuntu are available at:

If you prefer to use the official binary or build from source yourself, the following errors may have to be fixed:

If phantomjs dies on OSX with message "Killed 9" then the following code will fix it.

brew install upx
upx -d /usr/local/bin/phantomjs
@jasonhinkle
jasonhinkle / sign-eclipse.sh
Created August 31, 2015 21:15
Get rid of Eclipse firewall nag
sudo codesign --force --deep --sign - /Applications/Eclipse.app/
@jasonhinkle
jasonhinkle / wordpress.htaccess
Last active November 24, 2015 05:57
Limit access to Wordpress admin interface to specific IP address
# LIMIT WORDPRESS ADMIN ACCESS TO A WHITELISTED IP ADDRESS
# REPLACE 255.255.255.255 WITH YOUR OWN IP
RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin/.*
RewriteCond %{REQUEST_URI} !wp-admin/admin-ajax\.php$
RewriteCond %{REMOTE_ADDR} !^255.255.255.255$
RewriteRule ^(.*)$ - [R=403,L]