Skip to content

Instantly share code, notes, and snippets.

@dthanhtuan
dthanhtuan / logging_demo.py
Created December 3, 2023 14:42 — forked from dtaivpp/logging_demo.py
An introduction to logging in Python!
# Download this file with:
# curl -L https://gist.github.com/dtaivpp/a9b00957aa7d9cfe33e92aff8d50c835/raw/logging_demo.py -o logging_demo.py
import logging
#
# Named loggers
#
logger = logging.getLogger(__name__)
print(logger.name)
@dthanhtuan
dthanhtuan / jwtRS256.sh
Created June 23, 2022 07:04 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
Commands
------------
1. Build Docker Image
docker build -t test .
2. Run container /w image
docker run -d --publish 8888:5000 test
3. Login to ECR
aws ecr get-login-password --region REGIONHERE!!!! | docker login --username AWS --password-stdin ACCOUNTIDHERE!!!!.dkr.ecr.REGIONHERE!!!.amazonaws.com
@dthanhtuan
dthanhtuan / bypass_broken_images_middleware.rb
Created October 16, 2021 11:09 — forked from mcmire/bypass_broken_images_middleware.rb
Ignore requests for broken images in Capybara tests
# Instructions
# ------------
#
# * Save this as app/middlewares/bypass_broken_images_middleware.rb
# * Add the following inside of the Rails.application.configure block
# in config/environments/test.rb:
#
# config.middleware.insert_before(
#  ActionDispatch::DebugExceptions,
#  BypassBrokenImagesMiddleware,
@dthanhtuan
dthanhtuan / capybara cheat sheet
Created September 19, 2021 13:59 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@dthanhtuan
dthanhtuan / gcp_docker_rails.md
Created September 13, 2021 09:03 — forked from iEv0lv3/gcp_docker_rails.md
GCP Cloud Run :: Docker :: Rails

Google Cloud Platform (GCP) :: Docker :: Rails

This guide covers deploying a Docker image of a Rails and PostgreSQL application on Google Cloud Platform using Cloud Build, Container Registry, Cloud Key Management Service, Cloud Run, Cloud SQL, and Cloud Store. The following section provides links to a detailed guide created by a Google Developer Advocate which was the base for my build, but needed to be adjusted.

Cloud Run + Rails + PostgreSQL Guide

Google Cloud Run on Rails: a real life example Part 1

Google Cloud Run on Rails: a real life example Part 2

Google Cloud Run on Rails: a real life example Part 3

@dthanhtuan
dthanhtuan / nginx-config-auth-cert-ssl.md
Created September 3, 2021 13:30 — forked from alexishida/nginx-config-auth-cert-ssl.md
Tutorial to configure Nginx client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Original: https://gist.github.com/mtigas/952344

Convert SSL certificate from CRT format to PEM

openssl x509 -in server.crt -out server.der -outform DER
openssl x509 -in server.der -inform DER -out server.pem -outform PEM
@dthanhtuan
dthanhtuan / Brewfile
Created August 27, 2021 11:54 — forked from bbonamin/Brewfile
Capybara Selenium Webdriver: Headless Chrome (with file downloads!) & Headless Firefox
tap "caskroom/cask"
cask "google-chrome"
cask "firefox"
brew "chromedriver"
brew "geckodriver"
@dthanhtuan
dthanhtuan / README.md
Created June 22, 2020 03:34 — forked from arikfr/README.md
Setting up HTTPS with LetsEncrypt for Redash Docker Deployment
  1. Make sure the domain you picked points at the IP of your Redash server.
  2. Switch to the root user (sudo su).
  3. Create a folder named nginx in /opt/redash.
  4. Create in the nginx folder two additional folders: certs and certs-data.
  5. Create the file /opt/redash/nginx/nginx.conf and place the following in it: (replace example.redashapp.com with your domain name)
    upstream redash {
        server redash:5000;
    }
    
@dthanhtuan
dthanhtuan / web-fonts-asset-pipeline.md
Created February 17, 2020 03:31 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.