Skip to content

Instantly share code, notes, and snippets.

View tulioti's full-sized avatar

Tulio Fernandes tulioti

View GitHub Profile
@tulioti
tulioti / no-permission.sh
Created December 3, 2018 17:06
React native - adb devices -
$ adb devices
List of devices attached
device-id no permissions (user in plugdev group; are your udev rules wrong?); see [http://developer.android.com/tools/device.html]
Solution
Remove device
$ sudo -s
$ adb kill-server
$ adb start-server
Plug device
[
{"country_code": "BRA", "language_code": "PT", "name": "Brasil"},
{"country_code": "AFG", "language_code": "PS", "name": "Afeganistão"},
{"country_code": "AFS", "language_code": "EN", "name": "África do Sul"},
{"country_code": "AHL", "language_code": "NL", "name": "Antilhas Holandesas"},
{"country_code": "ALB", "language_code": "SQ", "name": "Albânia"},
{"country_code": "ANB", "language_code": "EN", "name": "Antigua"},
{"country_code": "AND", "language_code": "CA", "name": "Andorra"},
{"country_code": "ANG", "language_code": "PT", "name": "Angola"},
{"country_code": "ARA", "language_code": "AR", "name": "Arábia Saudita"},
// No arquivo Application.js
$( document ).ready(function() {
window.moneyMask = {
autoUnmask: true,
removeMaskOnSubmit: false,
radixPoint: ",",
groupSeparator: ".",
digits: 2,
autoGroup: true,
prefix: 'R$ ',
class RPN
def initialize(stack = [])
@stack = stack
end
def calculate
index = 0
while @stack.length > 1
case @stack[index]
when '+'
def insert(name)
ActiveRecord::Base.connection.execute("insert into schema_migrations (version) values (#{name})") rescue nil
end
files = Dir.glob("db/migrate/*")
files.collect { |f| f.split("/").last.split("_").first }.map { |n| insert(n) }
// Updated based on a list apparently from 2013 available on:
// http://concla.ibge.gov.br/classificacoes/por-tema/codigo-de-areas/codigo-de-areas
[
{
"name": "Acre",
"acronym": "AC",
"time_zone": "America/Rio_Branco",
"region": "Norte",
"capital": "Rio Branco",
"code": 12,
@tulioti
tulioti / check_db.rb
Created February 29, 2016 23:17
Rake task para checar os validates e orfãos em aplicações Rails
namespace :db do
namespace :data do
desc 'Validates all records in the database'
task :validate => :environment do
original_log_level = ActiveRecord::Base.logger.level
ActiveRecord::Base.logger.level = 1
puts 'Validate database (this will take some time)...'
Dir["#{Rails.root}/app/models/**/*.rb"].each { |f| require "#{ f }" }
@tulioti
tulioti / rspec_model_testing_template.rb
Created February 8, 2016 13:09 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@tulioti
tulioti / call_c_hello.py
Created February 5, 2016 13:41
Call C file in python
from subprocess import call
call(["./hello", "args", "to", "hello"])
@tulioti
tulioti / MySQL Backup
Created March 4, 2014 20:06
MySQL Backup
#!/usr/bin/env ruby
require 'mail'
mysql_username = 'root'
mysql_password = '123456'
mysql_database = 'test'
system("mysqldump --user=#{mysql_username} --password=#{mysql_password} #{mysql_database} > backup.sql")
# Credit to :