Skip to content

Instantly share code, notes, and snippets.

View tiagoefmoraes's full-sized avatar

Tiago Moraes tiagoefmoraes

View GitHub Profile
@tiagoefmoraes
tiagoefmoraes / keybase.md
Created September 22, 2014 20:08
keybase.md

Keybase proof

I hereby claim:

  • I am tiagoefmoraes on github.
  • I am tiagoefmoraes (https://keybase.io/tiagoefmoraes) on keybase.
  • I have a public key whose fingerprint is 61A3 00D4 8FB5 E0AF EE05 3D7F 597B 4699 75CF 0E23

To claim this, I am signing this object:

@tiagoefmoraes
tiagoefmoraes / mac-setup.md
Last active August 29, 2015 14:10
Mac os setup
  1. Go to App Store and install Xcode.
  2. Open and accept the terms
  3. Then go to the terminal and install "Command Line Tools":
xcode-select --install
@tiagoefmoraes
tiagoefmoraes / consolidate_migrates.sh
Created November 21, 2014 13:45
Consolidate migrates
#!/bin/bash
set -e
schema_migrate="db/migrate/20141107164010_schema.rb"
echo Running current migrations...
rm db/migrate/*
git checkout db/migrate/
rm -f $schema_migrate
dropdb -U postgres bedel_test
@tiagoefmoraes
tiagoefmoraes / step_by_step.rb
Created February 13, 2015 18:20
Define steps to process arrays in batches
def self.join(first, last)
if first.is_a?(Range) && last.is_a?(Range)
first.first..last.last
elsif first.is_a?(Range)
first.first..last
elsif first == last
first
else
first..last
end
@tiagoefmoraes
tiagoefmoraes / big_decimal_inspect.rb
Created March 5, 2015 15:39 — forked from henrik/big_decimal_inspect.rb
Better BigDecimal inspect for tests and diffs
class BigDecimal
def inspect
format("#<BigDecimal: %s>", to_s('F'))
end
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<!-- The required Stripe lib -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->
def escangalha_tudo obj, com_putaria=false
methods = obj.methods
#methods = obj.methods - Object.methods
methods.sort!
methods.each do |method|
clone = obj.clone
begin
puts "Method = #{method} => #{clone.send method}" unless !com_putaria and [:debugger, :breakpoint].include? method
rescue Exception => e
@tiagoefmoraes
tiagoefmoraes / gist:6341073
Created August 26, 2013 12:46
Ruby BigDecimal problems
#http://stackoverflow.com/questions/3039650/ruby-bigdecimal-sanity-check-floating-point-newb/3040859#3040859
9999999999999999900000000.0.to_d.to_s # => "10000000000000000000000000.0"
'9999999999999999900000000.0'.to_d.to_s # => "9999999999999999900000000.0"
(1.0e+25.to_d - 9999999999999999900000000.0.to_d).to_s # => "0.0"
('1.0e+25'.to_d - '9999999999999999900000000.0'.to_d).to_s # => "100000000.0"
(139.25.to_d + 74.79.to_d).to_s # => "214.04000000000001"
('139.25'.to_d + '74.79'.to_d).to_s # => "214.04"
@tiagoefmoraes
tiagoefmoraes / install.sh
Last active December 23, 2015 10:09
FreePascal silent install (and uninstall) on Ubuntu
wget http://downloads.sourceforge.net/project/freepascal/Linux/2.6.2/fpc-2.6.2.x86_64-linux.tar
tar -xvf fpc-2.6.2.x86_64-linux.tar
pushd fpc-2.6.2.x86_64-linux
echo 'echo /home/action/fpc' > answers.sh
echo 'echo Y' >> answers.sh
echo 'echo Y' >> answers.sh
echo 'echo Y' >> answers.sh
echo 'echo Y' >> answers.sh