Skip to content

Instantly share code, notes, and snippets.

View davidwaterston's full-sized avatar

David Waterston davidwaterston

View GitHub Profile
@davidwaterston
davidwaterston / startsWith
Last active October 13, 2015 11:47
Javascript: Case-sensitive 'starts with'
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function(str) {
return (this.lastIndexOf(str, 0) === 0);
};
}
@davidwaterston
davidwaterston / gist:4191070
Created December 2, 2012 21:05
Javascript: Case-sensitive 'contains'
if (typeof String.prototype.contains != 'function') {
String.prototype.contains = function(str) {
return this.indexOf(str) >= 0;
};
}
@davidwaterston
davidwaterston / gist:3927588
Created October 21, 2012 16:54
jQuery: Add 'maxlength' support to textarea fields. Validates cleanly in JSLint.
(function ($) {
'use strict';
$.textareaMaxlength = function () {
// Allows the 'maxlength' attribute to be used with textarea fields to limit the
// number of characters that can be entered.
// e.g <textarea id="myfield" maxlength="250"></textarea>
@davidwaterston
davidwaterston / gist:3902518
Created October 16, 2012 22:38
Git: Delete a remote tag
git tag -d abcde
git push origin :refs/tags/abcde
@davidwaterston
davidwaterston / gist:3767723
Created September 22, 2012 20:25
My Sublime Text 2 Preferences
{
"color_scheme": "Packages/User/Espresso Soda.tmTheme",
"default_line_ending": "windows",
"dictionary": "Packages/Language - English/en_GB.dic",
"draw_white_space": "all",
"font_face": "Source Code Pro",
"font_size": 13,
"word_wrap": "false",
"highlight_line": true,
"highlight_modified_tabs": true,
@davidwaterston
davidwaterston / gist:3755428
Created September 20, 2012 11:40
Oracle: Check if a table contains any data
select 1
from __TABLE_NAME__
where rownum = 1
@davidwaterston
davidwaterston / gist:3755420
Created September 20, 2012 11:39
Oracle: Check if a column exists in a table
select column_name as found
from user_tab_cols
where table_name = '__TABLE_NAME__'
and column_name = '__COLUMN_NAME__'
@davidwaterston
davidwaterston / gist:3755412
Created September 20, 2012 11:37
Oracle: Check if a table exists
select table_name
from user_tables
where table_name = '__TABLE_NAME__'
@davidwaterston
davidwaterston / gist:3742116
Created September 18, 2012 08:54
MySQL: Check if a table exists - version 3
select table_name as found
from information_schema.tables
where table_schema = SCHEMA()
and table_name = '__table_name__'
@davidwaterston
davidwaterston / gist:3741590
Created September 18, 2012 06:35
MySQL: Check if a table contains any data
select 1
from __table_name__
limit 1