Skip to content

Instantly share code, notes, and snippets.

@danwagnerco
danwagnerco / config.yml
Created January 9, 2015 12:46
An example DevKit yml file
# This configuration file contains the absolute path locations of all
# installed Rubies to be enhanced to work with the DevKit. This config
# file is generated by the 'ruby dk.rb init' step and may be modified
# before running the 'ruby dk.rb install' step. To include any installed
# Rubies that were not automagically discovered, simply add a line below
# the triple hyphens with the absolute path to the Ruby root directory.
#
# Example:
#
# ---
@danwagnerco
danwagnerco / _vimrc
Created January 31, 2015 18:04
Puts temp and swap files elsewhere when using Vim
set backupdir=%HOMEPATH%/temp
set directory=%HOMEPATH%/temp
@danwagnerco
danwagnerco / Gemfile
Created February 13, 2015 15:11
An example Gemfile config
# A sample Gemfile
source "https://rubygems.org"
# gem "rails"
gem "rspec", :require => "spec"
gem "timecop"
gem "ocra"
@danwagnerco
danwagnerco / date_type.rb
Last active August 29, 2015 14:16
Why does self.path = work instead of just path = ?
class DateType
attr_reader :entry
attr_accessor :path, :error_state
def initialize(entry)
@entry = entry.to_s
@path = ""
@error_state = false
end
@danwagnerco
danwagnerco / create_a_new_column_based_on_a_different_column.vb
Created June 5, 2015 11:57
Adding calculated columns FAST using variant arrays
Option Explicit
Public Sub CalculateResultsAndAddAsColumn()
Dim rngCategory As Range, rngResults As Range
Dim varCategory As Variant, varResults As Variant
Dim lngIdx As Long, lngLastRow As Long
Dim wksData As Worksheet
Dim strFirstLetter As String
'First things first: let's set up our basic variables
@danwagnerco
danwagnerco / convert_yyyymmdd_to_date.vb
Created June 11, 2015 02:54
This user-defined function (UDF) converts numbers in format YYYYMMDD to actual Excel dates
Option Explicit
Public Function CONVERT_YYYYMMDD_TO_DATE(rng As Range) As Date
Dim strText As String
'First we get the raw text from the Range (i.e. the Cell)
strText = rng.Text
'Then we can slice and dice the number, feeding it all into DateSerial
CONVERT_YYYYMMDD_TO_DATE = DateSerial(Left(strText, 4), _
Mid(strText, 5, 2), _
@danwagnerco
danwagnerco / combine_data_and_transpose_results_to_rows.vb
Last active August 29, 2015 14:22
This script combines data but writes the results to rows (with a new column for each item)
Option Explicit
Public Sub SplitCampersByCabin()
Dim lngLastRow As Long, lngIdx As Long, lngNextCol As Long, _
lngCabinRow As Long
Dim wksCampers As Worksheet, wksCabins As Worksheet
Dim varCamper As Variant, varCabin As Variant
Dim dicCampers As Scripting.Dictionary, _
dicCabins As Scripting.Dictionary
Dim strCamper As String, strCabin As String
@danwagnerco
danwagnerco / delete_blank_rows_based_on_a_varying_range.vb
Last active August 29, 2015 14:23
This script examines a dynamic range and deletes empty rows (based on the range size)
Option Explicit
Public Sub DeleteBlankRows()
Dim wks As Worksheet
Dim lngLastRow As Long, lngLastCol As Long, lngIdx As Long, _
lngColCounter As Long
Dim blnAllBlank As Boolean
'First things first: we identify our basic variables
Set wks = ThisWorkbook.Worksheets("hello")
@danwagnerco
danwagnerco / vim_vundle_and_conemu.md
Created June 22, 2015 20:43
This is a Windows-specific walkthrough for installing Vim, Vundle and ConEmu

Vim, Vundle and ConEmu on Windows

Let's start by getting it out on the table: Sublime Text is great, and version 3 should no longer be considered "abandonware" as of build 3065. Sublime Text served me very, very well over the years. That said, trying out new things is a major part of leveling-up, and in that vein Vim deserves a go. (And have you seen some of those thoughtbot guys flying around in Vim? It's awesome!)

Getting Vim up-and-running on your Windows machine doesn't have to be an all-day project. In this post, we'll walk through:

  • Installing gVim, which gives us both the "classic" command line version as well as the graphical version
  • Installing Vundle, the best way to handle Vim-enhancing packages
  • Installing ConEmu, a supercharged command line emulator for Windows
@danwagnerco
danwagnerco / import_all_data_files.vb
Last active June 8, 2016 16:30
This 3-part script collects data from CSV files, stores it in a master file and moves the already-imported CSVs into a "processed" folder
Option Explicit
Public Sub ImportAllDataFiles()
Dim strFile As String
Dim wbk As Workbook
Dim wks As Worksheet, wksMaster As Worksheet
Dim lngLastMasterRow As Long, lngFirstMasterRow As Long, _
lngLastDataRow As Long, lngLastDataCol As Long, lngIdx As Long, _
lngTimeZoneCol As Long, lngDateCol As Long
Dim rngTimeZoneCol As Range, rngDateCol As Range, _