Skip to content

Instantly share code, notes, and snippets.


Paulo Fidalgo fidalgo

View GitHub Profile
fidalgo / copy_attachments.rb
Created Mar 31, 2021 — forked from airblade/copy_attachments.rb
Copies S3-stored Paperclip attachments from one AR model to another
View copy_attachments.rb
# lib/paperclip/copy_attachments.rb
# Copies S3-stored Paperclip attachments from one AR model to another.
# This module should be mixed into the target AR model.
if >=
raise NotImplementedError, 'coded for aws-sdk v1'
fidalgo / signal.list
Last active Mar 24, 2020
Ruby signal.list under Fedora 31
View signal.list
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
ruby -e "puts Signal.list"
{"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "ABRT"=>6, "IOT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29}
fidalgo / serialize.rb
Created Feb 15, 2018
Rails JSON serialize
View serialize.rb
include ActiveModel::Serializers::JSON
def attributes
result = {}
object_methods = self.class.instance_methods(false) - self.class.public_methods(false)
object_methods.each do |method|
result[method] = send(method)

Keybase proof

I hereby claim:

  • I am fidalgo on github.
  • I am fidalgo ( on keybase.
  • I have a public key whose fingerprint is 5C31 2326 48B1 1BB7 95B9 62A0 10C8 4652 9545 964A

To claim this, I am signing this object:

View gist:5970617
# SQLite version 3.x
# gem install sqlite3
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
fidalgo /
Created Aug 30, 2011
_write method from msrplib to send a file in chunks.
def _write_file(self):
outgoing_file = self.outgoing_files.items[0][0]
number_of_chunks = 0
while outgoing_file.position < outgoing_file.size:
piece =
except Exception:
self.logger.err('error while reading file %r\n%s' % (outgoing_file, traceback.format_exc()))
self.logger.debug('_write_file: read %s bytes from %s' % (len(piece), outgoing_file))