Skip to content

Instantly share code, notes, and snippets.

View ntamvl's full-sized avatar
🏠
Working from home

Tam Nguyen ntamvl

🏠
Working from home
View GitHub Profile
@ntamvl
ntamvl / docker-remove-all-images-containers.md
Last active February 21, 2024 11:09
Docker: Remove All Images and Containers

Docker: Remove All Images and Containers

Starting over in this case means wiping clean my Docker images and containers, just to make sure there are no conflicts or duplicates. The following commands delete all containers and images:

Delete every Docker containers Must be run first because images are attached to containers

docker rm -f $(docker ps -a -q)

Delete every Docker image

@ntamvl
ntamvl / list-of-chrome-driver-command-line-arguments.md
Created January 30, 2019 04:20
List of Chrome Driver command line arguments

List of Chrome Driver command line arguments

Here is the list of Chrome Driver command line Arguments.

If you are using chrome Driver for Selenium WebDriver or Protractor or …. then these are a handy useful list of command line arguments that can be used.

You may use this to look at the usuage: https://code.google.com/p/chromium/codesearch#chromium/src/chromeos/chromeos_switches.cc

Run chromedriver –help to see command line arguments for your version.

@ntamvl
ntamvl / tip-upgrade-ruby-to-new-version.md
Last active December 26, 2018 03:32
Tip upgrade Ruby to new version

First, install latest Ruby Example:

rbenv install 2.6.0
rbenv global 2.6.0
rbenv rehash

After that I redid the following:

@ntamvl
ntamvl / [ReactJS] Detect Scrolls To Bottom.md
Last active February 21, 2024 11:10 — forked from enqtran/[ReactJS] Detect Scrolls To Bottom
[ReactJS] Detect Scrolls To Bottom
constructor(props) {
    super(props);
    this.state = {
        height: window.innerHeight,
        message: 'not at bottom'
    };
    this.handleScroll = this.handleScroll.bind(this);
}
@ntamvl
ntamvl / postgresql-show-size-of-all-databases.md
Last active February 21, 2024 11:10
PostgreSQL: Show size of all databases

PostgreSQL: Show size of all databases

SELECT pg_database.datname as "database_name", pg_database_size(pg_database.datname)/1024/1024 AS size_in_mb FROM pg_database ORDER by size_in_mb DESC;
SELECT
    pg_database.datname,
    pg_size_pretty(pg_database_size(pg_database.datname)) AS size
@ntamvl
ntamvl / rabbit_publisher.rb
Last active February 21, 2024 11:10
RabbitMQ Ruby Example
# an initializer
# gem install bunny
# written by: Tam Nguyen (twitter: @nguyentamvn)
require 'bunny'
require 'json'
class RabbitPublisher
def initialize(options = {})
bunny_config = {
@ntamvl
ntamvl / how_to_install_gem_idn-ruby.md
Created September 13, 2018 11:01
How to install gem idn-ruby

How to install gem idn-ruby

Ubuntu*

$ sudo apt -y install libidn11-dev
$ gem install idn-ruby  # Rails で使用する場合はプロジェクトディレクトリ内で bundle install

macOS

@ntamvl
ntamvl / fixed_kernal_task_high_cpu_on_macos.md
Last active February 21, 2024 11:10
Fixed the fan running high, kernel task taking up 500% cpu (high cpu) on macOS

Fixed the fan running high, kernel task taking up 500% cpu (high cpu)

Step 1: Disable SIP

Enter recovery mode

  • Shutdown your macbook
  • Press keys: Command + R
  • Press power button
  • Release keys Command + R when see Apple logo appear
  • Open Terminal app on recovery screen, then run below command:
@ntamvl
ntamvl / rails-sql-injection-like.md
Last active February 21, 2024 11:10
Rails SQL Injection with LIKE

Rails SQL Injection with LIKE

SQL ‘LIKE’ injection is a form of denial-of-service attack where an end-user adds wildcards to a SQL query that uses the ‘LIKE’ keyword. This greatly increases the time it takes to run the query. If your Rails application allows user searching using email:

users = User.includes(:profile).where("profiles.email LIKE ?", "#{term}%).all

A user can include percent signs in their search and vastly increase the query duration, slowing down the database.

What are the risks?

@ntamvl
ntamvl / change-wordpress-permalink-structure.md
Last active February 21, 2024 11:10
How to change Wordpress permalink structure