Skip to content

Instantly share code, notes, and snippets.

@westdavidr
westdavidr / .gitconfig
Created December 17, 2021 19:08
.gitconfig with az aliases
[alias]
pr = "!f() { exec az.cmd repos pr create \"$@\" --open; }; f"
repo = "!f() { exec az.cmd repos \"$@\"; }; f"
build = "!f() { exec az.cmd pipelines run --name \"$@\" --branch \"$(git rev-parse --abbrev-ref HEAD)\" --open; }; f"
@westdavidr
westdavidr / go-install-wsl.sh
Created February 27, 2018 16:01
Script to install Go 1.10 on WSL
#!/bin/bash
set -e
GVERSION="1.10"
GFILE="go$GVERSION.linux-amd64.tar.gz"
GOPATH="$HOME/projects/go"
GOROOT="/usr/local/go"
if [ -d $GOROOT ]; then
echo "Installation directories already exist $GOROOT"

Insert customer asynchronously

public async Task<Customer> InsertCustomer(Customer customer)
{
  var cmd = Sequelocity.GetDatabaseCommand();
  cmd.GenerateInsertForSqlServer(customer, "dbo.Customer");
  
  var newId = await cmd.ExecuteScalarAsync<long>();
  return await GetCustomerById(newId);
}

Fetch customer asynchronously

public async Task<Customer> GetCustomerById(long id)
{
  var cmd = Sequelocity.GetDatabaseCommand();
  cmd.SetCommandText(@"select top 1 * from dbo.Customer where CustomerId = @CustomerId");
  cmd.AddParameter("@CustomerId", id, DbType.Int64);
  
  return await cmd.ExecuteToObjectAsync<Customer>();
}
@westdavidr
westdavidr / nameize.rb
Last active May 25, 2016 13:18
Nameize Ruby
class String
SPACE = ' '
APOS = "'"
def nameize
case self
when / /
downcase.split(SPACE).each { |part| part.nameize! }.join(SPACE)
when /^(mac|mc)(\w)(.*)$/i
"#{$1.capitalize}#{$2.capitalize}#{$3}"
@westdavidr
westdavidr / yl-api-reference.md
Last active May 7, 2022 15:41
Young Living API reference