Skip to content

Instantly share code, notes, and snippets.

@phantom42
phantom42 / with_as.sql
Created February 19, 2014 14:34
oracle "with as" subquery
WITH typelist AS
(SELECT 0 AS n
FROM DUAL
WHERE 1 = 0
UNION
SELECT 1 AS n
FROM DUAL
UNION
SELECT 2 AS n
FROM DUAL)
@phantom42
phantom42 / where_case.sql
Created March 6, 2014 16:58
working CASE statement within a WHERE clause
DECLARE
v_filter varchar2(20) := 'All';
v_count number := 0 ;
BEGIN
dbms_output.enable(100000) ;
DBMS_output.put_line('running') ;
SELECT count(1) into v_count
FROM personnel p
WHERE NVL(P.TERMINATED_FLAG,'N') = 'N'
AND CASE WHEN (v_filter = 'Federal') THEN
@phantom42
phantom42 / indexOf.js
Created May 23, 2014 15:07
indexOf function for browsers lacking support (looking at you IE < 9). From answer on SO. http://stackoverflow.com/questions/143847/best-way-to-find-an-item-in-a-javascript-array#144172
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (obj, fromIndex) {
if (fromIndex == null) {
fromIndex = 0;
} else if (fromIndex < 0) {
fromIndex = Math.max(0, this.length + fromIndex);
}
for (var i = fromIndex, j = this.length; i < j; i++) {
if (this[i] === obj)
return i;
@phantom42
phantom42 / .gitattributes
Last active August 29, 2015 14:23
how to deal with line crlf issues in git
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
@phantom42
phantom42 / cfdump.html
Last active August 29, 2015 14:26
corrected headers for use when pasting a cfdump from a log file
<html>
<head>
<style>
table.cfdump_wddx,
table.cfdump_xml,
table.cfdump_struct,
table.cfdump_array,
table.cfdump_query,
table.cfdump_cfc,
@phantom42
phantom42 / cfscript qoq
Created December 12, 2012 14:22
the basic setup of a cfscript version of a query of queries.
// cfscript method of a query of queries
// there seems to be no supported way to create a qoq using the more common queryNew() cfscript
local.qoqObj = new Query(dbtype='query', sql="select * from qrySource where [sql conditional] ") ; // qrySource is an attribute set below
local.qoqObj.setAttributes(qrySource=local.actualSourceQuery) ; //
local.qryQoqResults = local.qoqObj.execute().getResult() ;
@phantom42
phantom42 / update_select
Created December 13, 2012 16:27
oracle update column with select from other table. http://www.sqlfiddle.com/#!4/ee7da/2306
UPDATE destTable d
SET d.column = (select column from sourceTable where id = [id])
WHERE [id] = 1
;
@phantom42
phantom42 / coldfusion.sublime-keymap.txt
Created December 2, 2015 13:52
sublime keymap contents for coldfusion. makes sublime similar to cfbuilder. enter this in preferences -> package settings -> coldfusion -> key bindings user
[
// cf tags
{ "keys": ["ctrl+shift+a"], "command": "insert_snippet", "args": {"contents": "<cfabort>" } },
{ "keys": ["ctrl+shift+d"], "command": "insert_snippet", "args": {"contents": "<cfdump var=\"#${0:$SELECTION}#\">" }},
{ "keys": ["ctrl+shift+o"], "command": "insert_snippet", "args": {"contents": "<cfoutput>${0:$SELECTION}</cfoutput>"}} ,
// comments & wrappers
// hash
{ "keys": ["ctrl+shift+h"], "command": "insert_snippet", "args": {"contents": "#${0:$SELECTION}#" } },
// single line comment
@phantom42
phantom42 / oracle updatedby trigger issue
Created January 2, 2013 20:23
template code to deal with the following discovered behavior -table rows were being updated without explicitly setting the updatedby value -:NEW reads the existing value of background_inv.updatedby and uses that to insert into the history table -this would create history logs associated with the incorrect user
CREATE OR REPLACE TRIGGER TIUD_BACKGROUND_INV
AFTER DELETE OR INSERT OR UPDATE
ON BACKGROUND_INV REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
v_new_updated_by := background_inv.updatedby%type ;
BEGIN
IF updating THEN
@phantom42
phantom42 / basic photoswipe
Created January 3, 2013 20:59
basic implementation of gallery displaying all jpgs in a folder
<cfscript>
currentDir = getDirectoryFromPath(getTemplatePath()) ;
currentfile = lcase(getFileFromPath(getTemplatePath()));
fileList = directoryList(currentDir,false,'query','*.jpg','asc') ;
</cfscript>
<!DOCTYPE html>
<html>
<head>
<title>PhotoSwipe</title>