Skip to content

Instantly share code, notes, and snippets.

@phantom42
phantom42 / printing out tables pt 2
Created February 22, 2013 04:44
Loops in JavaScript - Extra Tricks
var table = [
["Person", "Age", "City"],
["Sue", 22, "San Francisco"],
["Joe", 45, "Halifax"]
];
var rows = table.length ;
for (var i = 0 ; i < rows ; i++) {
var output = '' ;
var cells = table[i].length ;
for (var j = 0 ; j < cells; j++) {
@phantom42
phantom42 / __useful regular expressions.txt
Last active December 14, 2015 02:49
useful regular expressions and regex related stuff
-- collection of useful regular expressions
<!--- Get request from ColdFusion page contenxt. --->
<cfset objRequest = GetPageContext().GetRequest() />
<!--- Get requested URL from request object. --->
<cfset strUrl = objRequest.GetRequestUrl().Append(
"?" & objRequest.GetQueryString()
).ToString()
/>
-- '1,2,3' is the list of ids we would be searching against
SELECT *
FROM table
WHERE id IN
(
SELECT REGEXP_SUBSTR('1,2,3','[^,]+', 1, level) from dual
CONNECT BY REGEXP_SUBSTR('1,2,3', '[^,]+', 1, level) is not null
)
@phantom42
phantom42 / dump.cfm
Last active August 22, 2016 17:51
CF to dump scopes - especially useful for debugging or working on pages you're unfamiliar with
<!--- local/variable scope --->
<cfdump var="#getPageContext().getVariableScope()#" expand="false" label="variable scope"/>
<!--- all scopes LT cf10 --->
<cfdump var="#getPageContext().getBuiltInScopes()#"/>
<!--- all scopes cf10+ --->
<cfdump var="#getPageContext().getCFScopes()#"/>
@phantom42
phantom42 / IE8-indexOf.js
Created April 19, 2013 17:38
custom function to emulate indexOf method which is not supported by some browsers (IE8)
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
@phantom42
phantom42 / ie8_console_alert.js
Created April 22, 2013 16:26
console.log override function for browsers without console object - such is IE8 if debugging is not enabled.
var alertFallback = true;
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
if (alertFallback) {
console.log = function(msg) {
alert(msg);
};
} else {
console.log = function() {};
}
@phantom42
phantom42 / __anchors without href.css
Created April 29, 2013 17:06
selector to style simple anchor tags not being used for links.
a:not([href]) {
/* Styles for anchors without href */
}
@phantom42
phantom42 / gist:6000014
Last active December 19, 2015 18:38
command to export list of file names to a text file
dir /A:-D /N /S /B > filenames.txt
forfiles /S /C "cmd /c echo @path0x09@fsize0x09@fdate" > filenames.txt
for %f in (*.txt) do type "%f" >> combined.txt
SELECT *
FROM table a
WHERE A.column_name IN (
SELECT REGEXP_SUBSTR('1,2,3','[^,]+', level) FROM dual
CONNECT BY REGEXP_SUBSTR('1,2,3', '[^,]+', level) is not null
)