Skip to content

Instantly share code, notes, and snippets.

@dfmartin
dfmartin / packages.md
Created January 21, 2020 22:07
npm packages

cli tools

  • inquirer
  • commander
@dfmartin
dfmartin / async-sleep.ts
Created September 27, 2019 20:53
typescript async sleep
const sleep = (ms: number) => {
return new Promise(resolve => setTimeout(resolve, ms));
};
function snakeToCamel(str){
return str.toLowerCase()
// Replaces any - or _ characters with a space
.replace( /[-_]+/g, ' ')
// Removes any non alphanumeric characters
.replace( /[^\w\s]/g, '')
// Uppercases the first character in each group immediately following a space
// (delimited by spaces)
.replace( / (.)/g, function($1) { return $1.toUpperCase(); })
// Removes spaces
@dfmartin
dfmartin / .gitconfig
Last active August 23, 2017 16:18
git aliases
##
[alias]
co = checkout
cob = checkout -B
fp = fetch --prune
# log commands
lsg = log --all --graph --oneline --decorate
ls = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
@dfmartin
dfmartin / prepare-commit-msg
Created May 13, 2016 13:56
Prepare-commit-msg
# Currently in .git/hooks. Also check .git_template/
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
var x = People[0].Address.City;
// oops! Null reference exception. Need to replace with. . .
string x = string.Empty;
if(People != null) {
var p = People[0];
if (p != null) {
var a = p.Address;
if (a != null) {
x = a.City;
public class CurrentSession {
public CurrentSession() {
CreateDate = DateTime.Now;
}
public DateTime CreateDate { get; }
}
public string FirstName { get; set; } = "John";
public string LastName { get; set; } = "Doe";
public string FirstName { get; set; }
public string LastName { get; set; }
@dfmartin
dfmartin / uglyPropertyDefault.cs
Last active August 27, 2015 03:55
Ugly property defaults
private string _firstName = "John";
private string _lastName = "Doe";
public string FirstName {
get { return _firstName; }
set { _firstName = value; }
}
public string LastName {
get { return _lastName; }