Skip to content

Instantly share code, notes, and snippets.

View JFernandezWM's full-sized avatar

Jose C Fernandez JFernandezWM

View GitHub Profile
@JFernandezWM
JFernandezWM / 00.md
Created May 29, 2019 18:29 — forked from maxivak/00.md
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@JFernandezWM
JFernandezWM / fakeout.rb
Created April 12, 2019 16:30 — forked from matthutchinson/fakeout.rb
fake.rake - a takeout approach and rake task that generates some random fake data for a rails app (using ffaker)
# place this in lib/fakeout.rb
require 'ffaker'
module Fakeout
class Builder
FAKEABLE = %w(User Product)
attr_accessor :report
@JFernandezWM
JFernandezWM / notes.md
Created March 19, 2019 00:04 — forked from joakimk/notes.md
Building custom ruby images to use the latest versions (e.g. to get security fixes earlier)

Building custom ruby-alpine

Check the alpine version of the previous image.

alpine3.9 master$ docker run -it ruby:2.5.4-alpine sh
/ # cat /etc/alpine-release 
3.9.2
/ # ruby -v
ruby 2.5.4p155 (2019-03-13 revision 67245) [x86_64-linux-musl]
@JFernandezWM
JFernandezWM / nodejs-tcp-example.js
Created February 19, 2019 17:35 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@JFernandezWM
JFernandezWM / time_vs_datatime.md
Created January 24, 2019 15:07 — forked from pixeltrix/time_vs_datatime.md
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@JFernandezWM
JFernandezWM / GitCommitEmoji.md
Created January 11, 2019 15:49 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
@JFernandezWM
JFernandezWM / sublime-text-macos-context-menu.md
Created August 28, 2018 12:11 — forked from idleberg/sublime-text-macos-context-menu.md
“Open in Sublime Text” in macOS context-menu

Open in Sublime Text

  • Open Automator
  • Create a new Service
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n "$@"
  • Set “Pass input” to as arguments
  • Save as Open in Sublime Text
puma (3.11.4)
rails 5.2.0
ruby 2.5
dockerized environment
My puma.rb:
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
@JFernandezWM
JFernandezWM / nginxproxy.md
Created August 9, 2018 19:59 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@JFernandezWM
JFernandezWM / .rubocop.yml
Created August 1, 2018 16:27
Rubocop config for Ruby gems
AllCops:
TargetRubyVersion: 2.4.1
Exclude:
- "vendor/**/*"
- bin/*
Layout/DotPosition:
Description: Checks the position of the dot in multi-line method calls.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
Enabled: true
EnforcedStyle: leading