Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / _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 / 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
Last active August 29, 2015 14:13
Consolas setting for vim-airline inside your _vimrc
" set guifont=Meslo\ LG\ M\ for\ Powerline:h9 " <~ set the font
set guifont=Powerline\ Consolas:h11 " <~ set the font
set encoding=utf-8 " <~ set the encoding
let g:airline_powerline_fonts=1 " <~ activate the font in airline
@danwagnerco
danwagnerco / _vimrc
Last active August 29, 2015 14:12
Airline-specific _vimrc settings
set guifont=Meslo\ LG\ M\ for\ Powerline:h9 " <~ set the font
set encoding=utf-8 " <~ set the encoding
let g:airline_powerline_fonts=1 " <~ activate the font in airline
@danwagnerco
danwagnerco / _vimrc
Last active June 11, 2021 09:28
A starter _vimrc file for Vim 8.0 and vim-plug on Windows 10
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in