Skip to content

Instantly share code, notes, and snippets.

View brazilnut2000's full-sized avatar

Jon Crowell brazilnut2000

View GitHub Profile
@brazilnut2000
brazilnut2000 / Check if file or path exist.bas
Created July 5, 2013 20:17
VBA: Check to see if a given path or file exist
' Code based on snippet from John Walkenbach
Function FileExists(fileName) As Boolean
FileExists = Dir(fileName) <> ""
End Function
Function PathExists(pathName) As Boolean
' Returns TRUE if the path exists
On Error Resume Next
PathExists = (GetAttr(pathName) And vbDirectory) = vbDirectory
@brazilnut2000
brazilnut2000 / ColumnLetter
Created June 19, 2013 18:52
VBA: Returns the column letters for the column given.
Function ColumnLetter(colNum As Long) As String
Dim vArr
vArr = Split(Cells(1, colNum).Address(True, False), "$")
ColumnLetter = vArr(0)
End Function
@brazilnut2000
brazilnut2000 / ListAllTriggers.sql
Created May 22, 2013 13:35
SQL: List all triggers and definitions
select OBJECT_NAME(triggers.parent_id) as [object_name],
triggers.name,
triggers.parent_class_desc,
triggers.type_desc,
triggers.is_disabled,
triggers.is_instead_of_trigger,
OBJECT_DEFINITION(triggers.object_id)
as trigger_definition
from sys.triggers
@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; }
@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 / 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 / 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 / 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 / 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 / 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;