Skip to content

Instantly share code, notes, and snippets.

View iampeterbanjo's full-sized avatar
💭
Error24: not enough hours in the day

Peter Banjo iampeterbanjo

💭
Error24: not enough hours in the day
View GitHub Profile
@iampeterbanjo
iampeterbanjo / bbq-sample.js
Created October 29, 2010 23:43
example of using bbq jQuery plug-in
//listen for hash tag changes so we can remove the popup
$(window).bind('hashchange',
function(event){
//did we add or substract the hash?
var currentHash = window.location.hash;
currentHash = currentHash.slice(1);
if(window.console && debug){
console.log(['listings.js: hashchange event detected. currentHash is ', currentHash ].join(''));
}
@iampeterbanjo
iampeterbanjo / manifest.json
Created November 13, 2010 07:47
manifest file format for Google chrome extension
//there are exceptions to the rule
{
"property1" : "value1",
"property2" : "value2",
"property3" : ["value3.1","value3.2"]
}
@iampeterbanjo
iampeterbanjo / find-new-line-character.sql
Created March 2, 2011 20:25
using regular expressions in sql
SELECT NEW_LINE_INDEX
FROM (
SELECT INSTR(value, "\n")
AS NEW_LINE_INDEX
FROM table
WHERE value != ""
ORDER BY value
) findNewLines
WHERE NEW_LINE_INDEX > 0
;
@iampeterbanjo
iampeterbanjo / strip-new-line-character.sql
Created March 2, 2011 20:28
find and remove the new-line character using sql
SELECT TRIM(TRAILING SUBSTR(value,NEW_LINE_INDEX-1)
FROM value) as NEW_VALUE
FROM (
SELECT INSTR(value, "\n")
AS NEW_LINE_INDEX,
value
FROM table
WHERE value != ""
ORDER BY value
) findNewLines
@iampeterbanjo
iampeterbanjo / with-example.js
Created May 5, 2011 22:07
An example of using "with"
var table = {}, cloth = {};
table.clean = false;
cloth.clean = true;
// clean the table please
function wipeTable(cloth){
console.log("cleaning table");
if(cloth.clean){
table.clean = true;
@iampeterbanjo
iampeterbanjo / email-validation-by-regex.js
Created July 27, 2011 21:52
JavaScript email validation test
function log(message){
if(window.console){
console.log(message);
}
}
function warn(message){
if(window.console){
console.warn(message);
}
@iampeterbanjo
iampeterbanjo / String.removeSpecialCharacters.js
Created June 25, 2012 20:53
String.removeSpecialCharacters
// remove special characters from strings
// @return {string}
String.prototype.removeSpecialCharacters = function (){
return this.replace(/\t|\?|\r/gi,'').replace(/\n|\_|\-/gi,' ');
};
@iampeterbanjo
iampeterbanjo / test_String.removeSpecialCharacters.js
Created June 25, 2012 21:00
test String.removeSpecialCharacters
// checks our test conditions
// @param - condition (function) test to run
// @param - ref (string) to display for result
assert = function (condition, ref){
if(condition){
console.log("+ Passed: " + ref);
} else {
console.log("- Failed: " + ref, 'warn');
}
};
@iampeterbanjo
iampeterbanjo / decypher_niantic.js
Created November 9, 2012 21:21
decypher niantic crypto text
/*
* copy and paste into your browser's console to run and
* then use like so
* interprete("Jajwd tujwfynts wjfhmjx f wnxp-fxxjxxrjsy xyflj. Fy ymnx utnsy rd ijyjwrnsfynts nx ymfy snfsynh nx hfzxnsl rtwj ywtzgqj ymfs ny nx btwym")
*/
// simple deciphering scheme
var alphabet = "abcdefghijklmnopqrstuvwxyz";
var sillyAlphabet = "vwxyzabcdefghijklmnopqrstu";
var decrypt = {};
@iampeterbanjo
iampeterbanjo / gist:7041182
Last active December 25, 2015 21:19
Problem testing Alloy controllers based on alloy-unit-test
it('create with 2 items', function () {
item.set({
title: "The cloud atlas",
author: "David Mitchell"
});
item.save();
item.set({
title: "Design of design",
author: "Brooks"