Skip to content

Instantly share code, notes, and snippets.

View DavidBrower's full-sized avatar

David Brower DavidBrower

  • Civica MDM
  • Glasgow, Scotland
View GitHub Profile
@DavidBrower
DavidBrower / git-log-to-tsv.sh
Created March 13, 2020 16:31 — forked from pwenzel/git-log-to-tsv.sh
Git Log to Tab-Delimited CSV File
# Local Dates:
git log --date=local --pretty=format:"%h%x09%an%x09%ad%x09%s" > commits.local.tsv.txt
# ISO Dates:
git log --date=iso --pretty=format:"%h%x09%an%x09%ad%x09%s" > commits.iso.tsv.txt
@DavidBrower
DavidBrower / Robot.cs
Last active February 22, 2019 13:52
Technical Business Analyst Exercise
using System;
using System.Collections.Generic;
namespace Robotics
{
public static class Program
{
private static readonly Dictionary<string, Order> Orders = new Dictionary<string, Order>(StringComparer.OrdinalIgnoreCase)
{
["Start"] = Order.Start,
@DavidBrower
DavidBrower / commands.vim
Last active July 21, 2018 19:03
Vim Commands
<CR> : move to the start of the next line
- : move to the start of the previous line
^ : move to the start of the first word on the current line
0 : move to the start of the current line
$ : move to the end of the current line
P% : move to the point P% through the buffer
% : move between the matching bracket of a (), {}, [] pair
@DavidBrower
DavidBrower / .vimrc
Created July 20, 2018 21:13
vimrc file
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
set wildmenu
set wildmode=full
let mapleader = ","
" toggle on whether to show line numbers
nmap <leader>n :set number!<CR>
@DavidBrower
DavidBrower / docker.ps1
Created July 18, 2018 17:01
Docker Commands on Windows
Get-Content Dockerfile | docker build -
@DavidBrower
DavidBrower / Mongo.sh
Last active July 18, 2018 19:31
Mongo Commands
--Get execution stats for a query
db.people.find({"ssn": "720-38-5636"}).explain("executionStats")
--Get explain object
exp = db.people.find({"ssn": "720-38-5636"}).explain("executionStats")
@DavidBrower
DavidBrower / LazySingleton.cs
Last active July 13, 2018 23:40
Lazy Singleton
public sealed class Singleton
{
private static readonly Lazy<Singleton> lazy = new Lazy<Singleton>(() => new Singleton());
public static Singleton Instance {=> lazy.Value;
private Singleton() {}
}
@DavidBrower
DavidBrower / Singleton.cs
Created July 13, 2018 23:38
Jon Skeet's Preferred Singleton
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit
static Singleton()
{
}
@DavidBrower
DavidBrower / SQLServerRestoreInfo.sql
Last active May 19, 2018 13:00
Get SQL Server Restore Information
SELECT [rs].[destination_database_name],
[rs].[restore_date],
[bs].[backup_start_date],
[bs].[backup_finish_date],
[bs].[database_name] as [source_database_name],
[bmf].[physical_device_name] as [backup_file_used_for_restore]
FROM msdb..restorehistory rs
INNER JOIN msdb..backupset bs
ON [rs].[backup_set_id] = [bs].[backup_set_id]
INNER JOIN msdb..backupmediafamily bmf
@DavidBrower
DavidBrower / WindowsDeveloper.ps1
Created January 27, 2018 20:34
Set Up Windows Development Machine
# Set PowerShell execution policy
Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy Bypass -Scope Process -Force
# Install Chocolatey
ex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install Boxstarter
. { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force