Skip to content

Instantly share code, notes, and snippets.

View andreobriennz's full-sized avatar

Andre O'Brien andreobriennz

View GitHub Profile
@andreobriennz
andreobriennz / functional-fizzbuzz.js
Last active July 26, 2019 05:35
Functional / Declarative FizzBuzz
const isFizz = number => number % 5 === 0
const isBuzz = number => number % 3 === 0
const newArrayInRange = (min, max) => [...Array(max + 1).keys()].slice(min)
const fizzBuzz = (min, max) => newArrayInRange(min, max)
.map(number => {
if (isFizz(number) && isBuzz(number)) {
return 'fizzbuzz'
}
@apolloclark
apolloclark / postgres cheatsheet.md
Last active March 7, 2024 13:53
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@stevenharman
stevenharman / defaults.rb
Last active July 7, 2021 14:36
A subtle difference between Ruby's Hash.fetch(:key, :default) vs. (Hash[:key] || :default)
h = {
'a' => :a_value,
'b' => nil,
'c' => false
}
h.fetch('a', :default_value) #=> :a_value
h.fetch('b', :default_value) #=> nil
h.fetch('c', :default_value) #=> false
h.fetch('d', :default_value) #=> :default_value