Skip to content

Instantly share code, notes, and snippets.

View pedronsouza's full-sized avatar

Pedro Souza pedronsouza

  • @grupozap
  • São Paulo
View GitHub Profile
@pedronsouza
pedronsouza / gist:4722937
Created February 6, 2013 14:41
A little rake task for automate my routine of Commit all
namespace :git do
task :sent, :message, :repo do |t, args|
if args[:message].nil?
puts "You must define a message for the commit, example => rake git:commit['MyMessage']".colored.red
else
puts "Adding files, Commiting and pushing..".colored.yellow
exec("git add . && git add -u && git commit -m '#{args[:message]}' && git push #{args[:repo]}")
puts "All files sent to remote repository: #{:repo}".colored.green
@pedronsouza
pedronsouza / gist:5008900
Last active December 14, 2015 01:49
Installing gem with http-proxy option
gem install --http-proxy http://usuario:login@ip:porta rails
export http_proxy="http://username:password@ip:porta"
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
# download the last release of FirefoxOS here: http://www.rodrigopadula.com/arquivos/Keon-%20FirefoxOS%201.0.1.0-prerelease.tar.gz
Now, the commands
# Install the ADB and fastboot
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-fastboot
sudo adb reboot recovery # reboot your device in recovery mode
@pedronsouza
pedronsouza / bands.rb
Last active December 15, 2015 10:59
New notation for symbols array
# Com Ruby 1.9
BANDS = [:the_strokes, :black_keys, :arctic_monkeys]
# Agora, com Ruby 2.0
BANDS = %i[the_strokes black_keys, arctic_monkeys]
@pedronsouza
pedronsouza / gist:5249798
Created March 26, 2013 22:12
New method to_h
class Person
attr_accessor :name, :age
end
@person = Pessoa.new
@person.name = "Pedro Nicholas"
@person.age = 21
@person.to_h
#=> {:name => "Pedro Nicholas", :age => 21}
@pedronsouza
pedronsouza / gist:5249857
Created March 26, 2013 22:22
Refinements on Ruby 2.0
class String
def say_hi
"Hi #{self}!"
end
end
class MinhaClasse
puts "Pedro".say_hi
end
@pedronsouza
pedronsouza / gist:8456981
Last active April 1, 2017 22:51
Git config useful commands
[user]
name = <seu_nome>
email = <seu_email>
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
@pedronsouza
pedronsouza / NSDate+Extensions.m
Created April 25, 2014 18:51
Cool date extensions :D
#import "NSDate+Extensions.h"
@implementation NSDate (Extensions)
- (NSDate *)dateByMovingToBeginningOfDay {
unsigned int flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit |
NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
// [calendar setLocale:[NSLocale currentLocale]];
[calendar setTimeZone:[NSTimeZone timeZoneWithName:@"America/Sao_Paulo"]];