Skip to content

Instantly share code, notes, and snippets.

View baransu's full-sized avatar

Tomasz Cichocinski baransu

View GitHub Profile

General

  • Cut: C-w
  • Paste: C-y
  • Move selection line up: M-up (move-text-up)
  • Move selection line down: M-down (move-text-down)
  • Move cursor forward one char: C-f
  • Move cursor backward one char: C-b
  • Move cursor forward one world: M-f
  • Move cursor backward one world: M-b

Start

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

Stop

pg_ctl -D /usr/local/var/postgres stop -s -m fast
@baransu
baransu / syntactic_sugar.md
Last active July 28, 2016 22:40
Syntactic sugar

###Switch


This is horrible (change required)

  • variant A
switch(type) {
   case value: 
   break;

##Ideas

###Tuple

 const a = ('hello', 'world')
 a._1 // 'hello'

to

const a = { _1: 'hello', _2: 'world'}

Ideas

  • tail call optimization
  • last line function return
  • Math.pow() via operator not function

Key user moments

  • is it happening (loading)
  • is it usefull (initial render)
  • is it usable (call to action (record your voice))
export function createReducer(initialState, handlers) {
const match = (key, type) => (
key
.replace(/ /g, '')
.split(',')
.reduce((acc, k) => (
acc || type.indexOf(k) > -1 ? k : null
), null)
);
{
"type":"Page",
"value":"<!DOCTYPE html>",
"body":[
{
"type":"Tag",
"value":"html",
"attr":[
{
"type":"Attribute",
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerOrEqual = [a | a <- xs, a <= x]
larger = [a | a <- xs, a > x]
in quicksort smallerOrEqual ++ [x] ++ quicksort larger
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerOrEqual = [a | a <- xs, a <= x]
larger = [a | a <- xs, a > x]
in quicksort smallerOrEqual ++ [x] ++ quicksort larger