Skip to content

Instantly share code, notes, and snippets.

@javiervidal
javiervidal / vsc_shortcuts.md
Last active May 16, 2019 08:15
Visual Studio Code Shortcuts

Visual Studio Code Shortcuts

Shortcut Description
⌘ K ⌘ S Keyboard shortcuts
⇧ ⌥ ↓ Copy line down
⌥ W Switch window
⇧ ⌘ F Focus Search
⇧ ⌘ E Focus Explorer
⌥ T Focus terminal
@javiervidal
javiervidal / my_list.exs
Last active March 31, 2017 12:30
Lists and Recursion
defmodule MyList do
def map([], _func), do: []
def map([ head | tail ], func), do: [ func.(head) | map(tail, func) ]
end
MyList.map [1,2,3,4], fn (n) -> n*n end
MyList.map [1,2,3,4], &(&1 * &1)
@javiervidal
javiervidal / factorial1.exs
Last active March 31, 2017 12:31
Modules and Named Functions
defmodule Factorial do
def of(0), do: 1
def of(n), do: n * of(n-1)
end
@javiervidal
javiervidal / fizz_buzz.exs
Last active March 8, 2017 13:31
Anonymous functions
fizz_buzz = fn
(0,0,_) -> "FizzBuzz"
(0,_,_) -> "Fizz"
(_,0,_) -> "Buzz"
(_,_,a) -> a
end
IO.puts fizz_buzz.(0,0,"foo")
IO.puts fizz_buzz.(0,"foo","bar")
IO.puts fizz_buzz.("foo",0,"bar")
IO.puts fizz_buzz.("foo","bar","Atlas")
@javiervidal
javiervidal / 0_reuse_code.js
Created February 23, 2017 15:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@javiervidal
javiervidal / terminator.txt
Last active November 26, 2015 09:31
Shorcuts
Ctrl-Shift-E: will split the view vertically.
Ctrl-Shift-O: will split the view horizontally.
Ctrl-Shift-(arrow key): move "panel"
Alt-(arrow key): move the focus
@javiervidal
javiervidal / gist:f57d5553d25317b78fbc
Created May 26, 2014 12:41
init.d script for errbit
#!/bin/bash
### BEGIN INIT INFO
# Provides: APPLICATION
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the APPLICATION unicorns at boot
# Description: Enable APPLICATION at boot time.
### END INIT INFO
# This prevents capistrano from hanging when executing long tasks
# /etc/ssh/sshd_config
TCPKeepAlive yes
ClientAliveInterval 15
ClientAliveCountMax 5
# Restart sshd
# If you post to a Ruby on Rails REST API endpoint, then you'll get an
# InvalidAuthenticityToken exception unless you set a different
# content type in the request headers, since any post from a form must
# contain an authenticity token.
#
# This example shows you how to post to a rails endpoint.
require 'json'
@javiervidal
javiervidal / gist:5748246
Created June 10, 2013 12:02
PS1 with git branch
export PS1='\[\033[0;36m\][\h] \[\033[0;35m\]\u\[\033[0;33m\] \w\[\033[0;00m\] \[\033[0;37m\]$(__git_ps1 "(%s)")\[\033[0;00m\] $ '