Skip to content

Instantly share code, notes, and snippets.

View brazilnut2000's full-sized avatar

Jon Crowell brazilnut2000

View GitHub Profile
@brazilnut2000
brazilnut2000 / Detect IE Version.js
Last active December 15, 2015 12:29 — forked from padolsey/gist:527683
JS: ie version detection
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@brazilnut2000
brazilnut2000 / Detect SQL Server Version.sql
Last active June 20, 2019 00:01
SQL: Detect SQL Server Version
SELECT
CASE @@microsoftversion/ 0x01000000
WHEN 6 THEN 'You''ve got to be kidding me.'
WHEN 7 THEN 'SQL Server 7.0'
WHEN 8 THEN 'SQL Server 2000'
WHEN 9 THEN 'SQL Server 2005'
WHEN 10 THEN 'SQL Server 2008'
WHEN 11 THEN 'SQL Server 2012'
WHEN 12 THEN 'Time to update your gist, homey.'
END
@brazilnut2000
brazilnut2000 / WhatChanged.sql
Last active June 28, 2018 18:07
SQL: What Changed? Get a list of objects sorted by modified date.
/*
* Get a list of objects sorted by modified date.
* Allows you to quickly identify what has been
* added or changed.
*/
SELECT
modify_date, OBJECT_NAME(object_id ) 'Stored Procedure' , *
FROM
sys.procedures
@brazilnut2000
brazilnut2000 / SortNulls.sql
Last active December 15, 2015 23:09
SQL: Sort nulls in your result set.
/*
* Sort nulls in your result set.
*/
SELECT * FROM myTable
WHERE ...
ORDER BY CASE WHEN myCol IS NULL THEN 1 ELSE 0 END, myCol;
@brazilnut2000
brazilnut2000 / GreenBarMe.bas
Last active December 16, 2015 02:59
VBA: Alternate coloring for rows in a range.
' I need to do this frequently and like to be able to easily modify the colors I'm using for the banding.
' The following sub makes it very easy:
Sub GreenBarMe(rng As range, firstColor As Long, secondColor As Long, Optional borderColor As Long)
On Error GoTo AlternateGreenBarMe
Application.ScreenUpdating = False
rng.Interior.ColorIndex = xlNone
@brazilnut2000
brazilnut2000 / CSS3 Buttons.css
Last active December 16, 2015 14:59
CSS: CSS3 buttons from hellohappy.org
button::-moz-focus-inner {
border: 0; }
/* minimal
*******************************************************************************/
button.minimal {
background: #e3e3e3;
border: 1px solid #bbb;
border-radius: 3px;
-webkit-box-shadow: inset 0 0 1px 1px #f6f6f6;
@brazilnut2000
brazilnut2000 / abbreviations.html
Created April 26, 2013 13:40
HTML: Master list of abbreviations, extension of Chris Coyier's starting point on CSS-Tricks
Source for starting point: http://css-tricks.com/abbrs-for-web-nerd-acronymns/
See comments at bottom of hyperlinked post for links to WordPress plugins and other good ideas
<abbr title="Customer Relationship Management">CRM</abbr>
<abbr title="Content Management System">CMS</abbr>
<abbr title="Structured Query Language">SQL</abbr>
<abbr title="International Organization for Standards">ISO</abbr>
<abbr title="PHP: Hypertext Preprocessor">PHP</abbr>
<abbr title="HyperText Markup Language">HTML</abbr>
<abbr title="eXtensible HyperText Markup Language">XHTML</abbr>
@brazilnut2000
brazilnut2000 / Remove Duplicates.sql
Created May 1, 2013 20:12
SQL: Remove duplicate rows that have different ids
-- Source: http://stackoverflow.com/questions/18932/how-can-i-remove-duplicate-rows
DELETE MyTable
FROM MyTable
LEFT OUTER JOIN (
SELECT MIN(RowId) as RowId, Col1, Col2, Col3
FROM MyTable
GROUP BY Col1, Col2, Col3
) as KeepRows ON
MyTable.RowId = KeepRows.RowId
@brazilnut2000
brazilnut2000 / AppendTimeStampToCurrentWorkbook.bas
Created May 3, 2013 18:15
VBA: Append timestamp to the active workbook's name
Sub AppendTimeStampToCurrentWorkbook()
Dim myName As String
Dim newName As String
Dim last_dot As Long
myName = ActiveWorkbook.fullName
' InStrRev finds last occurrence of a string in another
last_dot = InStrRev(myName, ".")
newName = Left$(myName, last_dot - 1) & " - " & Format$(Now, "MM-DD-YYYY HH.MM AM/PM") & Mid$(myName, last_dot)
@brazilnut2000
brazilnut2000 / borderbox.css
Created May 13, 2013 04:53
CSS: Universal selector to apply box-sizing border-box with all vendor prefixes
/* apply a natural box layout model to all elements */
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }