Skip to content

Instantly share code, notes, and snippets.

@orangexception
orangexception / gist:b49c864544e87751cd2d
Created May 15, 2014 14:06
Regular Expression: Remove Every Other Line
Find
(.*)\n.*\n
Replace
\1\n
@orangexception
orangexception / gist:8323391
Created January 8, 2014 19:51
Bootstrap `button a` click issue in FireFox.
// FireFox?
if( $.browser.mozilla ) {
// Button Pressed?
$( "button" ).click( function() {
// Delegate Click & Click It
$( this )
// Delegate Click
.delegate( "a" , "click" , function ( event ) {
// Find Anchor
@orangexception
orangexception / gist:8285123
Last active January 2, 2016 09:48
A short fix for latest Bootstrap's collapsable accordions in IE7+.
// Bootstrap IE Collapsable Accordion Issue
if( $.browser.msie ) {
// Accordion Toggle Click Handler
$( ".accordion-toggle" ).click( function() {
// Get Accodion Root
domAccordion= $( this ).parents( ".panel-group" );
// Hide All Collapsable
domAccordion.children( ".collpase" ).removeClass( "in" );
@orangexception
orangexception / gist:6907723
Created October 9, 2013 20:24
SQL SERVER DATERANGE - LAST 30 DAYS
-- SQL SERVER DATERANGE
-- Generates a list the last 30 dates.
WITH DATERANGE AS (
SELECT
CAST( CONVERT( VARCHAR , DATEADD( dd , -30 , GETDATE() ) , 101 ) AS DATETIME ) AS DATE
UNION ALL
SELECT
DATEADD( dd , 1 , DATE )
FROM DATERANGE
// MySQL utf8 storage is limited to 3bit characters. When dealing with 4bit characters, then you need to alter the column.
ALTER TABLE `database`.`table` CHANGE COLUMN `Description` `Description` LONGTEXT CHARACTER SET 'utf8mb4' NULL DEFAULT NULL ;
@orangexception
orangexception / gist:4277332
Created December 13, 2012 15:50
Offending stored procedure outputs redundant/useless data. It also skews my expected resultsets, so I sent suppressed it.
-- SQL Server Suppression Table
-- Suppress Stored Procedure Output
-- Create Suppression Table
CREATE TABLE #SuppressionTable (
Value000 VARCHAR(MAX)
)
-- Insert ResultSet into Suppression Table
@orangexception
orangexception / gist:4155126
Created November 27, 2012 16:09
Uppercase Words (text-transform: uppercase)
// Uppercase Words (text-transform: uppercase)
sWords= REReplace( sWords , "(\w+)" , "\U\1\E" , "all";
@orangexception
orangexception / gist:4155118
Created November 27, 2012 16:07
Capitalize Words (text-transform: capitalize;)
// Capitalize Words (text-transform: capitalize;)
sWords= REReplace( sWords , "(\w+)" , "\u\1" , "all" );
@orangexception
orangexception / gist:4060217
Created November 12, 2012 16:12
Conditional SQL
-- # Conditional SQL Statements
-- This technique allows you to write a single query with conditional SQL without using the security hole of `EXECUTE`.
-- Skip The First Conditional
WHERE 1= 1
-- Conditional SQL:
-- This technique allows you to write a single query with conditional SQL without using the security hole of `EXECUTE`.
-- If @iUserStatusID is 0, then no limit is imposed.
-- If @iUserStatusID is not 0, then Users.StatusID must equal @iUserStatusID.
@orangexception
orangexception / gist:3973492
Created October 29, 2012 13:17
A Better Refactor for Mike Henke
<cffunction name= "minorNamesToString"
output= "false"
hint= "I convert a query of minor names to a string.">
<cfargument name= "qMinorNames" />
<cfset var sMinorNames= "" />
<cfset var sPreviousLastName= "" />
<!--- Edge Case: 1 Name in Query --->
<cfif qMinorNames.RecordCount EQ 1>