This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* From: https://blog.webdevsimplified.com/2020-07/relative-time-format/ | |
*/ | |
const formatter = new Intl.RelativeTimeFormat(undefined, { | |
numeric: 'auto' | |
}) | |
const DIVISIONS = [ | |
{ amount: 60, name: 'seconds' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Actions --- | |
$Copy <C-C> <C-Ins> | |
$Cut <C-X> <S-Del> | |
$Delete <Del> | |
$LRU | |
$Paste <C-V> <S-Ins> | |
$Redo <C-S-Z> <A-S-BS> | |
$SearchWeb | |
$SelectAll <C-A> | |
$Undo <C-Z> <A-BS> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install most recent version with GUI and GnuTLS: | |
`brew install emacs --HEAD --use-git-head --cocoa --with-gnutls` | |
Symlink homebrew app to make it visible via Spotlight: | |
`brew linkapps emacs` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- List databases -- | |
\list | |
SELECT datname FROM pg_database WHERE datistemplate = false; | |
-- List tables from current database -- | |
\dt | |
SELECT table_schema, table_name FROM information_schema.tables ORDER BY table_schema, table_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------- | |
-- Managing roles in PostgreSQL -- | |
---------------------------------- | |
-- Create -- | |
CREATE ROLE name WITH PASSWORD 'd94jsfsd' LOGIN; | |
-- Grant privileges to database -- | |
GRANT ALL PRIVILEGES ON DATABASE database_name TO name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby Spelling Corrector ported from Python script by Peter Norvig (http://norvig.com/spell-correct.html) | |
# | |
# Usage: | |
# s = Spelling.new('big.txt').read # Download one from: http://norvig.com/big.txt | |
# s.correct 'gaem of thrnoes' | |
# => "gaem of thrnoes" | |
class Spelling | |
LETTERS = ('a'..'z').to_a.join |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ways to execute a shell script in Ruby | |
# Example Script - Joseph Pecoraro | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Returns the result of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |