Skip to content

Instantly share code, notes, and snippets.

@triple-j
triple-j / jqui_quick_dialog.js
Created November 20, 2013 20:34
jQuery UI dialog based alert / confirm / prompt
(function( $, window, undefined ) {
"use strict";
/**
* display jqueryui dialog based alert
*/
window.dialog_alert = function( message, options ) {
var defaultOpts = {
title : "Alert",
// trim strings
if ( String.prototype.trim == undefined ) {
String.prototype.trim = function() { return this.replace(/(^\s+|\s+$)/g,''); }
}
@triple-j
triple-j / keycodes.js
Created November 25, 2013 15:30
key codes
window.Key = {
"BACKSPACE" : 8,
"TAB" : 9,
"ENTER" : 13,
"SHIFT" : 16,
"CTRL" : 17,
"ALT" : 18,
"PAUSE/BREAK" : 19,
"CAPS_LOCK" : 20,
"ESCAPE" : 27,
<?php
// counteract magic quotes if they are enabled (http://www.php.net/manual/en/security.magicquotes.disabling.php#71817)
if (get_magic_quotes_gpc()) {
function undoMagicQuotes($array, $topLevel=true) {
$newArray = array();
foreach($array as $key => $value) {
if (!$topLevel) {
$key = stripslashes($key);
}
if (is_array($value)) {
@triple-j
triple-j / recursiveAjax.js
Created November 27, 2013 15:12
Run a bunch of ajax requests linearly. Each request may have unique ajax settings, or shared settings. Explanation from http://stackoverflow.com/a/4414911 for which this code is based: * Make an array of objects that contain the needed elements for the requests. * Make a function that accepts the array. * The function removes the first item from…
// recursive ajax (based on code from from http://stackoverflow.com/a/4414911)
function recursiveAjax( arrSettings, commonSettings, raData ) {
if ( typeof raData === "undefined" ) raData = { total: arrSettings.length };
raData.index = raData.total - arrSettings.length;
var currentSettings = arrSettings.shift(); // Remove the first item from the Array.
var defaultSettings = { raTimeout: 100, raFinished: function( raData ){/* do nothing */} };
var settings = $.extend( {}, defaultSettings, commonSettings, currentSettings );
setTimeout( function() {
# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2010, Sebastian Staudt
# A nano configuration file to enable syntax highlighting of some Git specific
# files with the GNU nano text editor (http://www.nano-editor.org)
#
# Save this file to a directory of your choice and add it to your nanorc using
# include ${PATH_TO_THE_FILE}/git.nanorc
@triple-j
triple-j / config.fish
Last active August 29, 2015 14:03
~/.config/fish/config.fish
# http://herdrick.tumblr.com/post/24563032599/display-git-branch-and-dirty-status-in-fish-shell
set fish_git_dirty_color red
function parse_git_dirty
git diff --quiet HEAD ^&-
if test $status = 1
echo (set_color $fish_git_dirty_color)":"(set_color normal)
end
end
@triple-j
triple-j / debug.js
Created July 14, 2014 19:16
display debug info
(function( $, window, undefined ) {
"use strict";
/**
* Set DEBUG_LVL and Show/Hide debugging DOM Elements
*/
window.setDebugLevel = function( level ) {
level = parseInt( level, 10 );
window.DEBUG_LVL = isNaN(level) ? 0 : level;
@triple-j
triple-j / class.BitwiseFlag.php
Created August 6, 2014 19:41
Enable/Disable/View Bitwise Flags
<?php
/**
* @desc Enable/Disable/View Bitwise Flags
* (Useful when you need a group of true/false values)
* @author Jeremie J. Jarosh
*
* NOTE: slightly modifyed from code provided by 'wbcarts at juno dot com'
* (http://www.php.net/manual/en/language.operators.bitwise.php#108679)
*/
class BitwiseFlag {