Skip to content

Instantly share code, notes, and snippets.

View spadin's full-sized avatar
😃

Sandro Padin spadin

😃
View GitHub Profile
@spadin
spadin / sequential-promises.js
Created January 31, 2019 17:39
Run promises sequentially using Array#reduce
// https://css-tricks.com/why-using-reduce-to-sequentially-resolve-promises-works/
const sayHelloIn = (seconds) => () => new Promise((resolve, reject) => {
setTimeout(() => {
console.log(`Hello ${seconds} seconds later.`)
resolve();
}, seconds * 1000);
});
const sequentially = async (fns) => {
@spadin
spadin / kill-port
Last active December 7, 2018 17:18
End the process that's using a specific port.
#! /usr/bin/env bash
function kill-port () {
local length=$(($#-1))
local killargs=( "${@:1:$length}" )
shift $(($# - 1))
local port=$1
local pid
pid=$(lsof -t -i :"$port")
@spadin
spadin / sync-clock.sh
Created August 11, 2015 15:00
Sync clock after time has drifted
#! /bin/env bash
sudo ntpdate pool.ntp.org
@spadin
spadin / install-nokogiri.md
Last active August 29, 2015 14:18
Install Nokogiri on Mac w/Homebrew
xml2_dir=`brew info libxml2 | grep $(brew --cellar) | sed 's/ .*//'`
xslt_dir=`brew info libxslt | grep $(brew --cellar) | sed 's/ .*//'`

gem install nokogiri -- --use-system-libraries \
                        --with-xml2-config=${xml2_dir}/bin/xml2-config \

--with-xslt-config=${xslt_dir}/bin/xslt-config

@spadin
spadin / no_spec_finder.sh
Last active August 29, 2015 14:04
Find app files without specs
#! /usr/bin/env sh
app_dir=$1
spec_dir=$2
extension=$3
for file in $(find $app_dir -name "*${extension}" -print | sed "s!$app_dir*!!" | sed "s!$extension!!"); do
spec_file="${spec_dir}${file}_spec${extension}"
if [ ! -f $spec_file ]; then
echo $spec_file

Keybase proof

I hereby claim:

  • I am spadin on github.
  • I am sandropadin (https://keybase.io/sandropadin) on keybase.
  • I have a public key whose fingerprint is 7DA1 151D 0BB2 50B1 3708 6411 8FB9 6678 CA79 DF9B

To claim this, I am signing this object:

@spadin
spadin / unmap-help.vim
Created December 18, 2013 19:01
Unmap help in vim.
" I got this
nnoremap <F1> <NOP>
@spadin
spadin / strip-trailing-whitespaces.vim
Last active December 6, 2018 21:18
Simple function for striping trailing whitespace in Vim.
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
map <Leader>cw :call <SID>StripTrailingWhitespaces()<CR>
@spadin
spadin / delete-git-status.sh
Last active December 21, 2015 18:19
delete files that show up on `git status` list.
git status --porcelain |cut -c 1-3 --complement | rm
@spadin
spadin / .gitconfig
Created July 11, 2013 20:58
Create a zip archive of your current git branch.
[alias]
# Zip archive of current branch
# Usage: `git zip [filename]`, eg: `git zip ~/Desktop/source.zip`
zip = !sh -c 'git archive --format zip --output $1 `git rev-parse --symbolic-full-name --abbrev-ref HEAD`' -