This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"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"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No arquivo Application.js | |
$( document ).ready(function() { | |
window.moneyMask = { | |
autoUnmask: true, | |
removeMaskOnSubmit: false, | |
radixPoint: ",", | |
groupSeparator: ".", | |
digits: 2, | |
autoGroup: true, | |
prefix: 'R$ ', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RPN | |
def initialize(stack = []) | |
@stack = stack | |
end | |
def calculate | |
index = 0 | |
while @stack.length > 1 | |
case @stack[index] | |
when '+' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import call | |
call(["./hello", "args", "to", "hello"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 : |
NewerOlder