Skip to content

Instantly share code, notes, and snippets.

Sandro Padin spadin

Block or report user

Report or block spadin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@spadin
spadin / sequential-promises.js
Created Jan 31, 2019
Run promises sequentially using Array#reduce
View sequential-promises.js
// 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 Dec 7, 2018
End the process that's using a specific port.
View kill-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 / strip-trailing-whitespaces.vim
Last active Dec 6, 2018
Simple function for striping trailing whitespace in Vim.
View strip-trailing-whitespaces.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 / .gitconfig
Created Jul 11, 2013
Create a zip archive of your current git branch.
View .gitconfig
[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`' -
@spadin
spadin / unmap-help.vim
Created Dec 18, 2013
Unmap help in vim.
View unmap-help.vim
" I got this
nnoremap <F1> <NOP>
@spadin
spadin / delete-git-status.sh
Last active Dec 21, 2015
delete files that show up on `git status` list.
View delete-git-status.sh
git status --porcelain |cut -c 1-3 --complement | rm
@spadin
spadin / install-notes.md
Created Aug 30, 2011
Installation notes for installing nodejs, npm and redis on a fresh Ubuntu 11.04 server. Worked on Rackspace Cloud Servers.
View install-notes.md

Basic Install of Node.js from scratch on Ubuntu 11.04 Notes

$ apt-get update
$ apt-get install git-core curl build-essential openssl libssl-dev
$ git clone https://github.com/joyent/node.git && cd node
$ make
$ sudo make install
$ curl http://npmjs.org/install.sh | sudo sh

Cleanup node install files:

@spadin
spadin / sync-clock.sh
Created Aug 11, 2015
Sync clock after time has drifted
View sync-clock.sh
#! /bin/env bash
sudo ntpdate pool.ntp.org
@spadin
spadin / install-nokogiri.md
Last active Aug 29, 2015
Install Nokogiri on Mac w/Homebrew
View install-nokogiri.md
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 Aug 29, 2015
Find app files without specs
View no_spec_finder.sh
#! /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
You can’t perform that action at this time.