Skip to content

Instantly share code, notes, and snippets.

@vagnerzampieri
vagnerzampieri / hash.rb
Last active December 14, 2015 08:38
Inject hash and sum.
b = {"foo" => 100, "bar" => 300, "zaz" => 5}
c = {"foo" => 200, "bar" => 8}
a = [b, c]
a.inject({}) { |memo, i| memo.merge(i) { |key, first, second| first + second } }
=> {
"foo" => 300,
"bar" => 308,
@vagnerzampieri
vagnerzampieri / .bash_profile
Last active December 19, 2015 03:18
Para alertar se um comando foi encerrado.
# sudo apt-get install libnotify-bin
# para testar
# sleep 5; alert
alias alert_helper='history|tail -n1|sed -e "s/^\s*[0-9]\+\s*//" -e "s/;\s*alert$//"'
alias alert='notify-send -i /usr/share/icons/gnome/32x32/apps/gnome-terminal.png "[$?] $(alert_helper)"'
@vagnerzampieri
vagnerzampieri / find
Created July 23, 2013 16:37
Procurar uma expressão dentro de um arquivo
find . -name "*rb" -print | xargs grep 'Draper'
---
layout: post
title: "Blog do Frelleto"
author: Vagner Zampieri
date: 2013-07-20 9:17:05
categories: comunicado
---
O blog nasceu, fico muito feliz em anunciar isso e espero que esse seja o primeiro post de muitos. Se você quer conhecer mais o Frelleto fica ligado no blog e no [site][site].
@vagnerzampieri
vagnerzampieri / gist:6126674
Last active December 20, 2015 11:49
restore dump
pg_restore -c --username=postgres -W -d old_database ~/new_database.dump
@vagnerzampieri
vagnerzampieri / gist:6157818
Last active December 20, 2015 15:58
Delete Branches
git branch -D old_branch
git push origin --delete old_branch
git branch -d -r origin/old_branch
var FrelletoBlog = angular.module('FrelletoBlog', []);
FrelletoBlog.filter('highlight', function () {
return function (text, filter) {
if (filter === '') {
return text;
}
else {
return text.replace(new RegExp(filter, 'gi'), '<span class="match">$&</span>');
}
@vagnerzampieri
vagnerzampieri / gist:6313818
Created August 22, 2013 22:59
Heroku Toolbelt
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
@vagnerzampieri
vagnerzampieri / .irbrc
Created September 18, 2013 20:44
Config to PRY
begin
require "pry"
Pry.start
exit
rescue LoadError => e
warn "=> Unable to load pry"
end
@vagnerzampieri
vagnerzampieri / reject.rb
Created September 30, 2013 22:49
use reject! ruby
array = ['1', '', '2', '', 1, nil]
array.reject!(&:blank?)
=> [
[0] "1",
[1] "2",
[2] 1
]