Skip to content

Instantly share code, notes, and snippets.

View hugomaiavieira's full-sized avatar

Hugo Maia Vieira hugomaiavieira

View GitHub Profile
@hugomaiavieira
hugomaiavieira / consoles.md
Last active August 29, 2015 14:09
Xbox One vs PS4 (preço)
@hugomaiavieira
hugomaiavieira / extract.sh
Created November 6, 2014 03:26
Handy Extract Program
# Handy Extract Program
extract () {
if [[ -f $1 ]]; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
@hugomaiavieira
hugomaiavieira / upl.sh
Last active August 29, 2015 14:08 — forked from passalini/upload_to_upl_io.sh
Upload files to upl.io through command line
# This command receives a file as param, upload it to upl.io and copy the url to
# the clipboard
#
# Dependencies: curl and xclip
#
# Install: copy this code to your .bashrc or .zshrc
#
# Example:
#
# $ upload_file ~/Images/algorich-logo.png
@hugomaiavieira
hugomaiavieira / wait_for_ajax.rb
Last active August 29, 2015 14:08
Ajax testing with ruby and capybara
# Ajax testing with ruby and capybara
#
# Add this to spec/support
#
# When a link or button starts an ajax request, instead of use Capybara
# click_link, click_button and click_link_or_button methods use click_ajax_link,
# click_ajax_button and click_ajax_link_or_button methods. You can still use
# capybara methods and right after it, call wait_for_ajax method.
#
# This methods will wait until Capybara.default_wait_time for the ajax request
def insert_select2(team_name = nil)
# When it simulates an existing record, id is passed, and controller take it by id.
# It's simulating Select2 request for getting record on the query.
# When name is passed, it indicates that no record was found, creating a new one.
# This behavior is implemented on SalespointController#create.
execute_script("$('#app-team-modal .select2-focusser').val('#{team_name}').trigger('keyup')");
find('.select2-chosen').click
sleep 2
@hugomaiavieira
hugomaiavieira / typewatch.js
Created September 3, 2014 12:07
type watch for search
$(document).ready(function() {
var typewatch = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
}
})();
$('#search-modal').on('input', function () {
@hugomaiavieira
hugomaiavieira / lock-screen.sh
Last active September 8, 2022 16:12
Script to lock and turn off the screen on linux mint
#! /bin/bash
#
# How to use it
#
# $ chmod +x lock-screen
#
# $ ./lock-screen.sh
#
# You can create a custom keyborad shortcut (like Super+l) that call this script
#
@hugomaiavieira
hugomaiavieira / presence.rb
Created July 24, 2014 19:36
Do not use present? on ternary
# you may think to do this:
bar = foo || {}
# but foo can and empty string that is not falsy, so you do this:
bar = foo.present? ? foo : {}
# a better way to do it is this one:
bar = foo.presence || {}
@hugomaiavieira
hugomaiavieira / lorem.rb
Created October 10, 2013 23:13
Lorem ipsum generator in ruby for seed use
DICT = [ 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing',
'elit', 'sed', 'in', 'leo', 'sit', 'amet', 'quam', 'sollicitudin', 'accumsan',
'integer', 'eu', 'tempor', 'nisl', 'ut', 'ornare', 'aliquet', 'massa', 'vitae',
'posuere', 'aenean', 'neque', 'libero', 'dignissim', 'nec', 'tincidunt',
'vitae', 'placerat', 'sed', 'arcu', 'donec', 'elementum', 'cursus', 'lorem',
'nec', 'ullamcorper', 'etiam', 'feugiat', 'venenatis', 'sem', 'id', 'commodo',
'curabitur', 'in', 'nulla', 'mi', 'praesent', 'mattis', 'porttitor', 'ante',
'ac', 'pretium', 'tortor', 'vulputate', 'tincidunt', 'nunc', 'eu', 'risus',
'nec', 'enim', 'fringilla', 'scelerisque', 'id', 'quis', 'lorem', 'maecenas',
'elementum', 'mauris', 'eu', 'arcu', 'porttitor', 'pretium', 'sed', 'rhoncus',
@hugomaiavieira
hugomaiavieira / mini_profiler.rb
Created September 11, 2013 19:18
mini-profiler config
# Whether or not you want to log the queries about the schema of your tables.
# Default is 'false', 'true' in rails development.
Rack::MiniProfiler.config.skip_schema_queries = false
# Have Mini Profiler start in hidden mode - display with short cut. Defaulted to
# 'Alt+P'
Rack::MiniProfiler.config.start_hidden = true
# If whant to use on production, comment this.
if Rails.env.production?