Skip to content

Instantly share code, notes, and snippets.

View curl-in-brief.md

Basic

curl https://www.keycdn.com

Returning only the HTTP headers of a URL

curl -I https://www.keycdn.com
View sql-in-brief.md

ALTER

ALTER TABLE table_name
ADD column_name datatype;

AND

SELECT column_name(s) 
FROM table_name
@jeromecovington
jeromecovington / dynamic-fibonacci.js
Created Jun 8, 2021
Dynamic programming fibonacci example
View dynamic-fibonacci.js
// Naive recursion.
function fib1(n) {
if (n <= 1) {
return n
}
return fib1(n - 1) + fib1(n - 2)
}
{
console.log('fib1')
@jeromecovington
jeromecovington / diff-redis-dumps.md
Created Apr 23, 2021
Save and diff Redis dumps
View diff-redis-dumps.md
$ redis-cli --rdb dump-before.rdb save
$ redis-cli --rdb dump-after.rdb save
$ pip install rdbtools python-lzf
$ rdb --command diff dump-before.rdb | sort > sorted-dump-before.out
$ rdb --command diff dump-after.rdb | sort > sorted-dump-after.out
$ diff sorted-dump-before.out sorted-dump-after.out
View PartiallyRequired.ts
type PartiallyRequired<T, K extends keyof T> = Pick<T, K> & Partial<T>;
type Test = {
foo: string;
bar: string;
baz: string;
};
type Test1 = PartiallyRequired<Test, "foo">;
View regex-in-brief.txt
Matchers
^
Match starting position
.
Match any single character, enclose in bracket for literal dot
a.c -> "abc", etc.
[a.c] -> "a", ".", "c"
[ ]
Match single character, or character within range
[abc], [a-c] -> "a", "b", "c"
View cloudformation-in-brief.txt
AWSTemplateFormatVersion: "version date"
" String
Description:
" template metadata
" arbitrary yaml
" CloudFormation helper scripts
" cfn-init, cfn-signal, cfn-get-metadata, cfn-hup
" Resources can have Metadata (install scripts, etc.)
View vim-vscode-in-brief.txt
"word" motions (no special chars)
w
forward by word
b
backward by word
e
end of word
ge
end of word (backward)
View nsolid-in-brief.md

MacOS

  1. $ brew tap nodesource/nsolid
  2. $ brew install nsolid-console
  3. $ nsolid-console
  4. Run any script necessary to build app.
  5. $ NSOLID_APPNAME="my-app" NSOLID_COMMAND="localhost:9001" nsolid my-app/index.js
  6. Visit console at http://localhost:6753
  7. Start profiling in console.
  8. Exert load on local app at its usual port.
  9. Analyze and export results in console.
View tmux-in-brief.txt
tmux new-session -s my_session
tmux ls
tmux attach-session -t my_session
Ctrl+b c
Create a new window (with shell)
Ctrl+b w
Choose window from a list
Ctrl+b 0
Switch to window 0 (by number)