Skip to content

Instantly share code, notes, and snippets.

View jimboroberts's full-sized avatar

James Roberts jimboroberts

View GitHub Profile
@jimboroberts
jimboroberts / createNav
Created August 5, 2014 09:12
Creation navigation function array in bootstrap
function createNavigation(){
$currentFile = Explode('/', $_SERVER["PHP_SELF"]);
if(count($currentFile)>2){
if($currentFile[count($currentFile) - 1]=='index.php'){
$currentFile = '/'.$currentFile[count($currentFile) - 2].'/';
} else {
$currentFile = '/'.$currentFile[count($currentFile) - 2].'/'.$currentFile[count($currentFile) - 1];
}
@jimboroberts
jimboroberts / debugConsole
Created June 12, 2014 10:45
Php function to debug to console
//Simple helper to debug to the console
function debug_to_console($data) {
if ( is_array( $data ) )
$output = "<script>console.log( 'PaulBot Debug: " . implode( ',', $data) . "' );</script>";
else
$output = "<script>console.log( 'PaulBot Objects: " . $data . "' );</script>";
echo $output;
}
@jimboroberts
jimboroberts / linux
Created December 4, 2013 11:44
Linux shell tips and tricks
Check if remote port is open with bash:
echo >/dev/tcp/8.8.8.8/53 && echo "open"
Suspend process:
Ctrl + z
Move process to foreground:
fg
Generate random hex number where n is number of characters:
@jimboroberts
jimboroberts / validate.html
Created December 3, 2013 11:17
Bootstrap & jquery validation
<div id="errormsg"><ul></ul></div>
<div class="form-group">
<label class="col-sm-2 control-label">Title <div class="required">*</div></label>
<div class="col-sm-10"><input type="text" class="input-xlarge form-control" name="title_auc" id="title_auc" value="<?php echo $row_auction['title_auc']; ?>"/></div>
</div>
@jimboroberts
jimboroberts / 0_reuse_code.js
Created November 25, 2013 21:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jimboroberts
jimboroberts / gist:7214010
Created October 29, 2013 12:46
DataTables updates for Bootstrap 3
/* Set the defaults for DataTables initialisation */
$.extend( true, $.fn.dataTable.defaults, {
"sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
}
} );