Skip to content

Instantly share code, notes, and snippets.

View packages.md

cli tools

  • inquirer
  • commander
@dfmartin
dfmartin / async-sleep.ts
Created Sep 27, 2019
typescript async sleep
View async-sleep.ts
const sleep = (ms: number) => {
return new Promise(resolve => setTimeout(resolve, ms));
};
View vscode_settings.json
{
"[typescript]": {
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
}
},
"telemetry.enableTelemetry": false,
"telemetry.enableCrashReporter": false,
"gitlens.advanced.messages": {
@dfmartin
dfmartin / README.md
Last active May 2, 2019
React Router Hook
View README.md

React Hooks with React Router v5.0.0

requirements - so far as "this is what I used"

package.json

  "dependencies": {
    "react": "16.8.4",
    "react-dom": "16.8.4",
    "react-router": "5.0.0",
    "react-router-dom": "5.0.0",
View usefull_bash_scripts.sh
# count lines of code in current directory recursively
find . -name '*.ts* | xargs wc -l
View restore.sql
RESTORE DATABASE
[R.Data]
FROM DISK = '/var/opt/mssql/data/R.Data.bak'
WITH
MOVE 'R.Data' TO '/var/opt/mssql/data/R.Data.mdf',
MOVE 'R.Data_log' TO '/var/opt/mssql/data/R.Data.ldf',
REPLACE
View toCamelCase.js
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 Aug 23, 2017
git aliases
View .gitconfig
##
[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
View 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)
View NestedNulls.cs
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;