Skip to content

Instantly share code, notes, and snippets.

View nounderline's full-sized avatar
♦️
do like you mean it

Rafael Gutkowski nounderline

♦️
do like you mean it
View GitHub Profile
@nounderline
nounderline / timeago.js
Created October 29, 2022 17:12
Relative time ago with native Intl.RelativeTimeFormat in JS
/**
* From: https://blog.webdevsimplified.com/2020-07/relative-time-format/
*/
const formatter = new Intl.RelativeTimeFormat(undefined, {
numeric: 'auto'
})
const DIVISIONS = [
{ amount: 60, name: 'seconds' },
--- 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>
@nounderline
nounderline / gist:d0ca52c68d9a5a655362
Created February 16, 2015 21:54
Install Emacs on OS X
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`
@nounderline
nounderline / gist:8624080
Created January 25, 2014 21:41
[Postgres] Manage database
-- 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;
@nounderline
nounderline / manage-roles.sql
Last active January 4, 2016 12:49
[Postgres] Manage roles
----------------------------------
-- 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;
@nounderline
nounderline / spelling.rb
Created May 29, 2013 18:55
[Ruby] Spelling Corrector
# 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
@nounderline
nounderline / gist:5356839
Last active December 16, 2015 01:39 — forked from JosephPecoraro/shell-execution.rb
[Ruby] Cxecute a shell script (bash)
# 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