Skip to content

Instantly share code, notes, and snippets.

@yahonda
yahonda / ruby31onrails.md
Last active June 25, 2024 20:26
Ruby 3.1 on Rails

Ruby 3.1 on Rails

Actions required to use Ruby 3.1.0 with Rails

Rails 7.0.Z

  • Rails 7.0.1 is compatible with Ruby 3.1.0.
  • Rails 7.0.1 addes net-smtp, net-imap and net-pop gems as Action Mailbox and Action Mailer dependency, you do not need to add them explicitly in your application Gemfile anymore.
  • thor 1.2.1 has been released. You will not see DidYouMean::SPELL_CHECKERS.merge deprecate warnings anymore.

Rails 6.1.Z

  • Use Rails 6.1.5 to support database.yml with aliases and secrets.yml with aliases.
@fernandoaleman
fernandoaleman / mysql2-m1.md
Last active July 23, 2024 05:16
How to install mysql2 gem on m1 Mac

Problem

Installing mysql2 gem errors on Apple silicon M1, M2 or M3 Mac running macOS Sonoma.

Solution

Make sure mysql-client, openssl and zstd are installed on Mac via Homebrew.

Replace mysql-client with whichever mysql package you are using

@leastbad
leastbad / action_mailbox.md
Last active July 2, 2024 21:36
Action Mailbox: The Missing Manual

This is all you really need to know in order to make Action Mailbox work in development.

  1. Fire up ngrok http 3000 and make note of your subdomain for steps 3 and 8.
  2. Create a Mailgun account because they offer sandbox addresses; grab your domain from the Dashboard.
  3. Go into Receiving and create a catch-all route pointing to: https://XXX.ngrok.io/rails/action_mailbox/mailgun/inbound_emails/mime
  4. Add your Mailgun API key to your credentials:
action_mailbox:
 mailgun_api_key: API KEY HERE
@jillbert
jillbert / nb_zapier_push.js
Last active August 28, 2018 18:16
Push Zapier JS Variables to NationBuilder
var apiUrl = 'https://YOUR_NATION_URL.nationbuilder.com/api/v1/people/push?access_token=YOUR_ACCESS_TOKEN';
var data = JSON.stringify({
"person":{
"email":inputData.email,
"first_name":inputData.first_name,
"last_name":inputData.last_name,
"external_id":inputData.id,
"tags":[inputData.purchase],
}
@jling90
jling90 / index.md
Last active May 16, 2017 04:20
random js thot of the day ft. moment.js
var moment = require('moment')
a = moment("2017-05-16")
b = moment("2017-05-17")
c = moment("2017-05-17")

We should always use moment(a).isBefore(b) instead of a < b. Not because the latter does not work (both forms work!); but rather, we might be tempted to assume something like a == b or a === b behaves similarly.

@hmnhf
hmnhf / mandrillapp_invalid_sender_characters.rb
Last active November 13, 2020 09:20
Mandrillapp invalid sender characters
# I was encountering this exception: Net::SMTPServerBusy: 401 4.1.7 Bad sender address syntax
# First I searched to see if there's any documentation around this issue but didn't find anything,
# so I wrote this snippet to find those invalid characters.
require 'mail'
Mail.defaults do
delivery_method :smtp, {
port: 25,
address: "smtp.mandrillapp.com",
@hSATAC
hSATAC / postgresql-template1-encodinf.pp
Last active January 3, 2019 22:09
Set postgresql template1 encoding to UTF8 in Puppet.
exec { "postgresql-template1-utf8":
command => "psql -c \"update pg_database set datistemplate=false where datname='template1';\" &&
psql -c 'drop database Template1;' &&
psql -c \"create database template1 with owner=postgres encoding='UTF-8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;\"
",
user => "postgres",
path => "/usr/bin",
unless => "/usr/bin/psql -Atc \"select pg_encoding_to_char(encoding) from pg_database where datname='template1'\" | /bin/grep -c UTF8"
}
@vparihar01
vparihar01 / nokogiri_libxml_homebrew_lion_installation.sh
Created June 25, 2013 07:01
How to fix: Nokogiri Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0. dlopen bundle.open. Using homebrew on lion to install nokogiri and lixml
FIXME:
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
or
ERROR -: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
@trcarden
trcarden / gist:3295935
Created August 8, 2012 15:28
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@ShirtlessKirk
ShirtlessKirk / luhn.js
Last active May 17, 2024 08:05
Luhn validation algorithm
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,