Skip to content

Instantly share code, notes, and snippets.

View vyper's full-sized avatar

Leonardo Saraiva vyper

View GitHub Profile
@vyper
vyper / rubocop.rb
Last active October 28, 2020 17:09 — forked from skanev/rubocop.rb
A Rubocop wrapper that checks only added/modified code
#!/usr/bin/env ruby
# A sneaky wrapper around Rubocop that allows you to run it only against
# the recent changes, as opposed to the whole project. It lets you
# enforce the style guide for new/modified code only, as opposed to
# having to restyle everything or adding cops incrementally. It relies
# on git to figure out which files to check.
#
# Here are some options you can pass in addition to the ones in rubocop:
#
@vyper
vyper / Dockerfile
Created September 23, 2016 19:34
Dockerfile to generate protos
FROM ruby:2.3.0-alpine
ENV PROTOBUF_VERSION 3.0.2
RUN apk add --update build-base autoconf automake libtool git perl && \
curl --location --silent --output /tmp/protobuf.tar.gz https://github.com/google/protobuf/archive/v$PROTOBUF_VERSION.tar.gz && \
tar xfz /tmp/protobuf.tar.gz -C /tmp/ && \
cd /tmp/protobuf-$PROTOBUF_VERSION && \
./autogen.sh && \
./configure --prefix=/usr && \
@vyper
vyper / bash-in-parallel.sh
Created June 20, 2015 08:14
Looping in parallel using bash
function wait_run_in_parallel()
{
local number_to_run_concurrently=$1
if [ `jobs -np | wc -l` -gt $number_to_run_concurrently ]; then
wait `jobs -np | head -1`
fi
}
function get_status() {
local line=$1
@vyper
vyper / capybara.md
Last active August 29, 2015 14:17 — forked from steveclarke/capybara.md

Capybara

save_and_open_page

Matchers

have_button(locator)
@vyper
vyper / development.sphinx.conf
Last active December 25, 2015 17:29
Example for sphinx using accent in search
indexer
{
}
searchd
{
listen = 127.0.0.1:9306:mysql41
log = /home/vyper/Documents/Projects/sphinx-test/log/development.searchd.log
query_log = /home/vyper/Documents/Projects/sphinx-test/log/development.searchd.query.log
pid_file = /home/vyper/Documents/Projects/sphinx-test/log/development.sphinx.pid
@vyper
vyper / database.yml
Last active December 23, 2015 15:09
Arquivos para o post: Melhorando o tempo de pesquisa utilizando Sphinx
development:
adapter: mysql2
username: root
password:
database: sphinx_test_development
test:
adapter: mysql2
username: root
password:
@vyper
vyper / sandbox-with-autocomplete.sh
Created September 6, 2013 12:57
Use 'sandbox' to change a work directory
# sandbox
SANDBOX_DIR=~/Documents/Projects/
_sandbox() {
local current=${COMP_WORDS[COMP_CWORD]}
local options="reset `ls $SANDBOX_DIR`"
COMPREPLY=( $(compgen -W "$options" $current) )
}
cd_sandbox() {
cd $SANDBOX_DIR/$1
}
@vyper
vyper / fullpath.sh
Created July 29, 2013 14:38
full path of script
echo "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@vyper
vyper / remove_older_kernel_debian_like.sh
Last active December 16, 2015 01:39
Apagar os "kernéis" antigos
dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | grep -v libc-dev| xargs sudo aptitude -y purge
String.prototype.slugify = function() {
return this.toLowerCase().trim()
.replace(/[áàãâä]/g, "a")
.replace(/[éèẽêë]/g, "e")
.replace(/[íìĩîï]/g, "i")
.replace(/[óòõôö]/g, "o")
.replace(/[úùũûü]/g, "u")
.replace(/ç/g, "c")
.replace(/(\ |_)+/, " ")
.replace(/(^-+|-+$)/, "")