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 / 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 / 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 / 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 / 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);
}
// output a warning or message to the console
// depending on how the test passed
function assert(test, description){
console[!!test ? 'log' : 'warn']('Test %s: returned %s', description, test);
}
// i can't remember where I found this
// deep link to modal items
function deepLinkIntoModals() {
// queryStrip
function queryStrip(string) {
string = string.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + string + '=([^&#]*)'),
results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ''));
// modified version of http://www.guffa.com/Programming_archive.aspx?id=16
var getQuerystring = function (key, from){
var re = new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi')
, r = []
, m
;
while ((m=re.exec(from)) != null) r.push(m[1]);
return (r.join(',') || '').replace('/','');
// https://stackoverflow.com/questions/31077319/regex-get-query-string-without-hash
var parseUri = function (uri){
var anchor = document.createElement('a')
;
anchor.href = uri;
return {
protocol: anchor.protocol
, host: anchor.host
, hostname: anchor.hostname
, port: anchor.port
@iampeterbanjo
iampeterbanjo / app.yaml
Created October 3, 2015 20:39 — forked from darktable/app.yaml
GAE: App.yaml designed for serving a static site on Google App Engine (Python). Copy your static html and files into a folder called "static" next to app.yaml. Contains a bunch of mimetype declarations from html5boilerplate's .htaccess. May not be neces
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest