Skip to content

Instantly share code, notes, and snippets.

View davidwaterston's full-sized avatar

David Waterston davidwaterston

View GitHub Profile
@davidwaterston
davidwaterston / gist:3741571
Created September 18, 2012 06:30
MySQL: Check if a table exists - version 2
show tables like '__table_name__'
@davidwaterston
davidwaterston / gist:3741564
Created September 18, 2012 06:27
MySQL: Check if a column exists in a table
select column_name
from information_schema.columns
where table_schema = '__database_name__'
and table_name = '__table_name__'
and column_name = '__column_name__'
@davidwaterston
davidwaterston / gist:3741543
Created September 18, 2012 06:21
MySQL: Check if a table exists - version 1
select table_name as found
from information_schema.tables
where table_schema = '__database_name__'
and table_name = '__table_name__'
@davidwaterston
davidwaterston / Geolocating IP Addresses for free using geoPlugin.net and ColdFusion
Created July 8, 2012 00:05
A ColdFusion function to grab geolocation details for an IP address using the free geoPlugin.net service.
<cfcomponent name="geoPlugin" output="no">
<cffunction name="ipLocation" access="remote" returntype="struct" displayname="ipLocation" output="no">
<!---
This function takes an IP address and passes it to http://www.geoplugin.net, a free GeoLocation service that
returns info about where that IP address is located i.e. city, country, etc. The returned data from geoPlugin
is cleaned up and returned as a ColdFusion structure.
Where the IP address is not passed in then geoPlugin.net will use the IP of the calling page. The IP used is
always returned in the 'geoplugin.request' variable.
@davidwaterston
davidwaterston / Javascript now() function
Created June 24, 2012 09:00
A cross-browser Javascript shim function to return the number of milliseconds elapsed since either the browser navigationStart event (using performance.now or browser equivalent) or the UNIX epoch, depending on availability.
var now = (function() {
// Returns the number of milliseconds elapsed since either the browser navigationStart event or
// the UNIX epoch, depending on availability.
// Where the browser supports 'performance' we use that as it is more accurate (microsoeconds
// will be returned in the fractional part) and more reliable as it does not rely on the system time.
// Where 'performance' is not available, we will fall back to Date().getTime().
// jsFiddle: http://jsfiddle.net/davidwaterston/xCXvJ