Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am thalessr on github.
  • I am thalessr (https://keybase.io/thalessr) on keybase.
  • I have a public key ASAuGGgb20scPpKl6ivbMemP909gFPannBRPaFzQoRDe6go

To claim this, I am signing this object:

brew update && \
brew upgrade && \
brew cask update && \
brew cleanup && \
brew cask cleanup
@thalessr
thalessr / array_utils.rb
Created November 2, 2015 16:50
This code will flatten an array of arbitrarily nested arrays
class ArrayUtils
def initialize
@flat = []
end
# Recursive method to flatten an array instead of using the ruby mehod .flatten
def flatten(array)
array.each do |a|
@thalessr
thalessr / mailer
Last active August 29, 2015 14:15
Delayed email delivery
Sending email asynchronously using sidekiq, delayed jobs or others. Simply call the method delay before your mailer method
Eg:
From YourMailer.mailer_method(params).deliver
To YourMailer.delay.mailer_method(params), YourMailer.delay_for(1.minute).mailer_method(params) or
YourMailer.delay_until(1.month.from_now).mailer_method(params)
There are many ways to get the most recently users. The most common is:
`User.order('created_at DESC').first(5)`
and I personally prefer to use
`User.limit(5).reverse_order`
because I think it is more the "ruby way"
@thalessr
thalessr / subl
Created January 5, 2015 16:28
Sublime text2 - Remove trailing whitespace on save
Go to SublimeText 2 > Preferences > User Settings or press ⌘,
And then add the line
"trim_trailing_white_space_on_save": true
it should look like as the following
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_size": 14.0,
"ignored_packages":
@thalessr
thalessr / gist:2da47657d0f020972ac5
Created January 5, 2015 16:00
ImageMagick missing jpeg delegate
type in your terminal
convert -version
```
Version: ImageMagick 6.8.9-8 Q16 x86_64 2014-12-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib freetype jng jpeg lcms ltdl lzma png xml zlib
```
Probably your delegates will be DELEGATES bzlib freetype png x11 xml zlib