Skip to content

Instantly share code, notes, and snippets.

View mattcan's full-sized avatar

Matthew Cantelon mattcan

View GitHub Profile

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 28/10/2014
  • Original post

Developer Cheat Sheets

This are my cheat sheets that I have compiled over the years. Tired of searching Google for the same things, I started adding the information here. As time went on, this list has grown. I use this almost everyday and this Gist is the first bookmark on my list for quick and easy access.

I recommend that you compile your own list of cheat sheets as typing out the commands has been super helpful in allowing me to retain the information longer.

@mattcan
mattcan / FlipName.bas
Last active September 29, 2015 10:08
Flip "Lastname, Firstname" to "Firstname Lastname"
'''
' Note that Split always returns a 0-indexed array
'''
Option Explicit
Function flip_name(comma_sep_name As String)
Dim name_parts() As String
name_parts = Split(comma_sep_name, ",")
@mattcan
mattcan / commandcolumn_visibility.vb
Created January 17, 2012 21:44
DevExpress ASPxGridView CommandColumn Visibility
Private Sub theGrid_DataBound(ByVal sender as Object, ByVal e as System.EventArgs) Handles theGrid.DataBound
' Create a GridView object and cast the GridView object we're working on to it
Dim gv As ASPxGridView = TryCast(sender, ASPxGridView)
' Loop through the visible columns (as they are set in the ASP or somewhere else in your code)
For i As Integer = 0 To gv.VisibleColumns.Count
' Match the type of the current column to the GridViewCommandColumn type and
' then hide the column and break out of the loop
If TypeOf (gv.VisibleColumns(i)) Is GridViewCommandColumn Then
@mattcan
mattcan / count-to-ten.b
Created May 17, 2012 14:41
A program that counts to ten, outputting each value along the way
++++++++++ set loop counter to ten
[
>>>>+++ increase 5th cell by 3
<<<<- decrease loop counter
]
>>>>++ increase 5th cell by 2 to make the 'Space' ASCII code
<<<<++++++++++ reuse 1st cell as loop counter increase to ten
[
>+++++ increase 2nd cell by 5
>+++++ increase 3rd cell by 5
@mattcan
mattcan / GRANT.sql
Created October 6, 2015 22:54
Setting execute on a schema in SQL Server tends to evade my memory
GRANT EXECUTE ON SCHEMA :: <schema here> TO <user/role here>;
@mattcan
mattcan / SplitColumn.vb
Last active October 13, 2015 14:37
Splits text in one column into two
Sub SplitColumn( _
ByVal LastRow As Long, _
ByVal DataCol As String, _
ByVal FirstPartCol As String, _
ByVal SecondPartCol As String, _
ByVal DelimCharacter As String _
)
Dim data_col As String, col_one As String, col_two As String, delimiter As String
data_col = DataCol
@mattcan
mattcan / FindValue.vb
Last active October 14, 2015 00:18
Takes the name of a field in a string, the character after the value, and returns the value in an adjacent column. I used this to parse a few hundred URLs for the value of the username.
Sub FindValue()
Dim ws As Excel.Worksheet
Set ws = ActiveSheet
Dim i As Integer, lastRow As Integer
lastRow = 328
Dim fromCol As String, toCol As String, field As String, delim As String
fromCol = "C"
@mattcan
mattcan / TextStreamFactory.bas
Last active December 11, 2015 20:49
I always forget how to create a new text file so I put together this factory. You will need to reference the Microsoft Scripting Runtime library in your VBA project.
' Make sure you've referenced the Microsoft Scripting Runtime library in your project
' In the VBA Editor: Tools > References...
Function TextStreamFactory(ByVal NewFileName As String) As Scripting.TextStream
Dim fs As New Scripting.FileSystemObject
Dim ts As Scripting.TextStream
Set ts = fs.CreateTextFile(NewFileName)
Set TextStreamFactory = ts
End Function
@mattcan
mattcan / StringFormat.vb
Last active December 15, 2015 16:19
Works similar to String.Format in .NET. Takes in a string and fills in the {n} variables.
' Needs error checking and to handle more than just strings
' Usage:
' StringFormat("My {2} dogs are {0}, {3}, and {1}.", "Dumbo", "Tim", "3", "Marsha")
Function StringFormat(ByVal ParseTemplate As String, ByVal Arg As String, ParamArray Args() As Variant) As String
Dim lastItemIndex As Integer, combinedArgs() As Variant
' Combine the passed in arguments
If Not UBound(Args) < LBound(Args) Then
ReDim combinedArgs(0 To UBound(Args) + 1)