Skip to content

Instantly share code, notes, and snippets.

View bernardobarreto's full-sized avatar
🚴‍♂️

Bernardo bernardobarreto

🚴‍♂️
  • 01:00 (UTC -03:00)
View GitHub Profile
@bernardobarreto
bernardobarreto / apt-fast.sh
Created April 4, 2012 06:21 — forked from gabriellima/gist:1828218
custom apt-fast (based on 0.02 by Matt Parnell)(english version)
# !/bin/sh
# CUSTOM version by Gabriel Lima (http://www.github.com/gabriellima) (@glima5)
# * Check portuguese (pt_BR) apt-get output
# * support '--force-yes' param to pass through user response
# * pass '-n10' to axel, to use 10 connections instead of default number
# * show packages installed or upgraded in the end of command execution
# apt-fast v0.02 by Matt Parnell http://www.mattparnell.com, this thing is fully open-source
# if you do anything cool with it, let me know so I can publish or host it for you
// ==UserScript==
// @name Udacity EXT - Auto next video&quiz
// @description Udacity Extension -- Automatically go to the next video or quiz question upon reaching the end of the current one
// @namespace http://sepczuk.com/
// @version 0.2
// @include http://www.udacity.com/view*
// @match http://www.udacity.com/view*
// @copyright 2012, Damian Sepczuk, Hugo Lopes Tavares // Bernardo B. Marques
// ==/UserScript==
@bernardobarreto
bernardobarreto / gist:2877446
Created June 5, 2012 19:59 — forked from viniciusteles/gist:556029
Sete Atitudes para Hackear a Indústria de Software
Sete Atitudes para Hackear a Indústria de Software
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
@bernardobarreto
bernardobarreto / gist:ddb977312d445dfa436d
Created November 15, 2015 15:11 — forked from alisterlf/gist:3490957
JAVASCRIPT:Remove Accents
function RemoveAccents(strAccents) {
var strAccents = strAccents.split('');
var strAccentsOut = new Array();
var strAccentsLen = strAccents.length;
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";
for (var y = 0; y < strAccentsLen; y++) {
if (accents.indexOf(strAccents[y]) != -1) {
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1);
} else
@bernardobarreto
bernardobarreto / database.yml.example mysql2
Created February 16, 2016 04:49 — forked from erichurst/database.yml.example mysql2
Rails 3 database.yml examples
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@bernardobarreto
bernardobarreto / web-fonts-asset-pipeline.md
Created May 5, 2016 16:40 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@bernardobarreto
bernardobarreto / README.md
Created June 23, 2017 04:01 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

ESTADOS_BRASILEIROS = [
["Acre", "AC"],
["Alagoas", "AL"],
["Amapá", "AP"],
["Amazonas", "AM"],
["Bahia", "BA"],
["Ceará", "CE"],
["Distrito Federal", "DF"],
["Espírito Santo", "ES"],
["Goiás", "GO"],
@bernardobarreto
bernardobarreto / termux.sh
Created May 19, 2018 23:34 — forked from paresharma/termux.sh
Rails on Termux
apt update && apt upgrade
apt install ruby vim git nodejs
apt install ruby-dev libxml2-dev libxslt-dev pkg-config make clang
gem install nokogiri -- --use-system-libraries
apt install libsqlite-dev
gem install sqlite3
@bernardobarreto
bernardobarreto / browser_testing_on_wsl.md
Created August 22, 2018 20:19 — forked from danwhitston/browser_testing_on_wsl.md
Browser testing for Ruby from within Windows Subsystem for Linux

This is a rough guide to setting up browser testing through Selenium on Windows Subsystem for Linux (WSL), aka Bash on Ubuntu on Windows. It assumes the following environment:

  • Windows 10, running WSL
  • A Ruby dev environment, running inside WSL
  • Code that we want to test using a web driver, in this case Selenium, with a Capybara and RSpec test framework

The coding project folders are stored in the main Windows filing hierarchy and accessed via dev/mnt, but that makes no real difference to development and testing other than making it possible to edit the code using a GUI based editor within Windows.

The problem with browser testing in WSL is that it relies on opening and controlling a web browser, and browsers don’t work on WSL at present as it deliberately doesn’t include X Windows or some other GUI manager - it’s meant to be command line after all. So while you can apt-get firefox, trying to actually run it isn’t going to work.