Skip to content

Instantly share code, notes, and snippets.

View CarlosCD's full-sized avatar

Carlos A. Carro Duplá CarlosCD

  • Firstup@socialchorus
  • Maryland, USA
View GitHub Profile
@CarlosCD
CarlosCD / suppress_ruby_output.rb
Created February 2, 2021 17:08 — forked from moertel/suppress_ruby_output.rb
Temporarily suppress STDOUT and STDERR (ruby)
# Temporarily redirects STDOUT and STDERR to /dev/null
# but does print exceptions should there occur any.
# Call as:
# suppress_output { puts 'never printed' }
#
def suppress_output
original_stderr = $stderr.clone
original_stdout = $stdout.clone
$stderr.reopen(File.new('/dev/null', 'w'))
$stdout.reopen(File.new('/dev/null', 'w'))
@CarlosCD
CarlosCD / ssl_puma.sh
Created June 1, 2021 14:03 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@CarlosCD
CarlosCD / echo.rb
Last active December 8, 2022 20:08
Echo server (testing some webhooks locally)
#!/usr/bin/env ruby
# frozen_string_literal: true
%w(json webrick).each do |gem_name|
begin
Gem::Specification.find_by_name(gem_name)
rescue Gem::MissingSpecError
puts "Installing the '#{gem_name}' Ruby gem..."
system "gem install #{gem_name}"
end