Skip to content

Instantly share code, notes, and snippets.

@vuongpd95
vuongpd95 / rails-heroku-cheatsheet.txt
Last active September 28, 2020 01:22
Useful terminal commands while working with rails & heroku
# n for line number, r for recursive, -i for case insensitive, -R for regular expression
grep -n -r -i -R --exclude-dir=node_modules '--include=*.'{slim,erb,js} "PATTERN" .
LOCAL:
# create a rake task
rails g task <task-name> # change lib/task/<task-name>.rake to desc the task
# to create database base on database.yml
rails db:create # OR rake db:create
@vuongpd95
vuongpd95 / wordpress-as-sub-rails-app.md
Last active June 2, 2022 21:22
Setup wordpress as subdirectory (/blog) of an existing app
Name: Flash
Serial: eNrzzU/OLi0odswsqnHLSSzOqDGoca7JKCkpsNLXLy8v1ytJTczVLUotKNFLzs8FAJHYETc=
if anyone wants to thank ETH: 0x527c2aB55b744D6167dc981576318af96ed26676
Thank you!
@vuongpd95
vuongpd95 / make-your-own-ruby-gem.md
Last active September 7, 2020 19:23
Make your own Ruby Gem
@vuongpd95
vuongpd95 / rails-docker-compose.md
Created September 27, 2020 13:53
docker-compose for Rails application on Local
# docker/webapp/Dockerfile
FROM ruby:2.6.6

SHELL ["/bin/bash", "-c"]
RUN apt-get update -qq && apt-get install -y postgresql-client memcached tzdata nano
# Install node 12, yarn
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
@vuongpd95
vuongpd95 / lib-mina-local_assets-tasks.rb
Last active February 15, 2021 01:34
Local Precompile Assets for low spec VM
# In deploy.rb
# require_relative '../lib/mina/local_assets/tasks'
# ...
# task :deploy do
# # uncomment this line to make sure you pushed your local branch to the remote origin
# # invoke :'git:ensure_pushed'
# invoke :'local_assets:clobber'
# invoke :'local_assets:precompile'
# invoke :'local_assets:sync_to_remote_tmp'
@vuongpd95
vuongpd95 / customize-rails-trix-toolbar.md
Last active June 18, 2023 14:42
How to customize Rails trix editor toolbar
var Trix = require("trix")
require("@rails/actiontext")

Trix.config.blockAttributes.heading2 = {
  tagName: 'h2',
  terminal: true,
  breakOnReturn: true,
  group: false
}
@vuongpd95
vuongpd95 / gcp-command-cheatsheet.md
Last active October 31, 2020 06:33
GCP command cheatsheet

GCP Data flow

For VM instance, it's essential that:

  • Before a VM instance can be created, compute API should be enabled gcloud services enable compute.googleapis.com
  • zone and machine-type are required in order to create a VM instance
  • Metadata can be passed to the instance by using --metadata={{ attribute name }}={{ attribute value }} which then can be retrieved by curl -H "Metadata-Flavor: Google" http://http://metadata.google.internal/computeMetadata/v1/instance/attributes/{{ attribute name }} while inside the instance.
  • To set startup script of a VM instance from a file --metadata-from-file startup-script={{ Relative path to the startup script }}. But, do remember, startup-script is just an attribute so we can also do --metadata startup-script='...'. startup-script can be read by curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/attributes/startup-script
  • For the VM instance to be able to use any GCP services, it needs to have the
@vuongpd95
vuongpd95 / .vimrc
Last active November 26, 2021 02:44
My .vrimrc
" Install Vim
" sudo apt-get install vim
" Install Vundle
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" $ vim
" $ :PluginInstall
set shell=/bin/bash
set nocompatible
set encoding=utf-8
set fileencodings=urf-8
@vuongpd95
vuongpd95 / vim-essentials.md
Last active November 26, 2021 02:42
My Vim essentials

My Vim Essentials

Those are the commands which I frequently use & feel it effective & easy.

Working with .vimrc, Vundle

  • :source % to reload vimrc
  • :PluginInstall to install plugin using Vundle

Navigations