Skip to content

Instantly share code, notes, and snippets.

View alexanmtz's full-sized avatar
🎯
Focusing

Alexandre Magno alexanmtz

🎯
Focusing
View GitHub Profile

Image source

https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png

Try resize it!

  • ![](https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png | width=100)
@alexanmtz
alexanmtz / build_openssl_dylib.sh
Created December 2, 2020 14:02 — forked from tmiz/build_openssl_dylib.sh
Build latest OpenSSL Universal Binary on OSX
#!/bin/bash
OPENSSL_VERSION="1.0.1o"
curl -O -L http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_i386
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_x86_64
cd openssl_i386
@alexanmtz
alexanmtz / install-openssl-from-src-mac
Last active December 2, 2020 11:26 — forked from byronmansfield/install-openssl-from-src-mac
Install OpenSSL from source Mac OS X
# Install older OpenSSL 1.0.0 from source on Mac OS X to install Ruby version compatible (like 1.8.7)
# prepare workspace
mkdir -p ~/code/build-from-src/ && cd $_
# download source code
curl -LO https://www.openssl.org/source/openssl-1.0.0.tar.gz
# expand tar
tar -xzvf openssl-1.0.0.tar.gz
@alexanmtz
alexanmtz / put_post_json_rails_5_integration_test.md
Created September 26, 2020 00:49 — forked from dteoh/put_post_json_rails_5_integration_test.md
PUT or POST JSON in a Rails 5 ActionDispatch::IntegrationTest

In Rails 5, the preferred base class for testing controllers is ActionDispatch::IntegrationTest.

If you have an API that receives parameters as JSON request bodies, here are some helper methods to facilitate testing:

class ActionDispatch::IntegrationTest
  def put_json(path, obj)
    put path, params: obj.to_json, headers: { 'CONTENT_TYPE' => 'application/json' }
  end
@alexanmtz
alexanmtz / dummy_controller.rb
Created September 26, 2020 00:20 — forked from psobocinski/dummy_controller.rb
Asserting on a JSON response in a Rails controller test with MiniTest
class DummyController < ApplicationController
def do
render json: { balance: 50 }
end
end
@alexanmtz
alexanmtz / gist:ff05ea8e944d95bd5649852bf484e214
Created June 5, 2019 08:39 — forked from sergiosvieira/fluxo-trabalho-git.md
Fluxo de Trabalho do Git para Pequenas Equipes
Fluxo de Trabalho no Git
========================
Primeiro crie um branch de desenvolvimento no seu repositório local:
$ git checkout --track origin/development
1. Trabalhe em sua tarefa, continuamente comitando em intervalos regulares para manter
o rastro daquilo que você fez.
@alexanmtz
alexanmtz / git-export
Created January 2, 2019 10:01 — forked from kristofferh/git-export
"Export" a git repository to zip file
git archive --format zip --output /full/path/to/zipfile.zip master
@alexanmtz
alexanmtz / heroku_env_copy.sh
Created August 1, 2018 11:10 — forked from nabucosound/heroku_env_copy.sh
Script to copy environment variables from an existing heroku app to another one
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
@alexanmtz
alexanmtz / SparkPost cURL Create (POST) Transmissions API Example
Created December 21, 2017 19:18 — forked from bdeanindy/SparkPost cURL Create (POST) Transmissions API Example
cURL POST Example to send an email using the SparkPost Transmissions API
curl \
-H "Content-Type: application/json" \
-H "Authorization: <REPLACE_WITH_YOUR_API_KEY>" \
-X POST -d '{"options":{"open_tracking":true,"click_tracking":true},"return_path":"bounces@<REPLACE_WITH_YOUR_SENDING_DOMAIN_HERE>","metadata":{"some_useful_metadata":"testing_sparkpost"},"substitution_data":{"signature":"<REPLACE_WITH_YOUR_FIRST_AND_LAST_NAME>"},"recipients":[{"address":{"email":"<REPLACE_WITH_YOUR_EMAIL_ADDRESS>","tags":["learning"],"substitution_data":{"customer_type":"Platinum","first_name":"<REPLACE_WITH_YOUR_FIRST_NAME>"}}}],"content":{"from":{"name":"Awesome Company","email":"testing@<REPLACE_WITH_YOUR_SENDING_DOMAIN>"},"subject":"My first SparkPost Transmission","reply_to":"Awesome Company ","text":"Hi {{address.first_name}}\r\nYou have just sent your first email through SparkPost!\r\nCongratulations,\r\n{{signature}}","html":"<strong>Hi {{address.first_name}},</strong><p>You have just sent your first email through SparkPost!</p><p>Congratulations!</p>{{signature}}"}}' \
https://api.sparkpos

Integrating Stripe with Rails (Concise)

This written tutorial is a concise version of this tutorial, which covers building a payment system into a Rails app using Stripe.js. It assumes a basic familiarity with Ruby on Rails, Git and the command-line.

What's covered

  • Setting up a basic Rails app with a scaffold generator
  • Integrating Stripe charges
  • Deploying to Heroku