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 / how-can-i-know-the-absolute-path-of-a-running-process.md
Created April 11, 2018 02:47
[Linux] How can I know the absolute path of a running process

[Linux] How can I know the absolute path of a running process

ps auxwe

or

ps -ef
@ntamvl
ntamvl / low-disk-watermark-exceeded-on.md
Created April 10, 2018 08:43
low disk watermark [??%] exceeded on

low disk watermark [??%] exceeded on

I know it is old post, but my comment can make someone happy. In order to specify watermark in bytes values (gb or mb) you have to add cluster.routing.allocation.disk.watermark.flood_stage to your elasticsearch settings file - elasticsearch.yml. Complete example:

cluster.routing.allocation.disk.threshold_enabled: true 
cluster.routing.allocation.disk.watermark.flood_stage: 200mb
cluster.routing.allocation.disk.watermark.low: 500mb 
cluster.routing.allocation.disk.watermark.high: 300mb   
@ntamvl
ntamvl / elasticsearch_how_to_turn_red_to_green_or_yellow_status.md
Created April 10, 2018 08:14
[ElasticSearch] How to turn red to Green or yellow status

[ElasticSearch] How to turn red to Green or yellow status

PUT _settings
{
    "index" : {
        "number_of_replicas" : 0
    }
}
@ntamvl
ntamvl / fixed-compile-assets-for-react.md
Created April 2, 2018 12:30
Fixed compile assets for React

Fixed compile assets for React

bundle exec rails webpacker:binstubs
@ntamvl
ntamvl / actioncable-how-to-use-dynamic-channels.md
Created March 22, 2018 04:10
ActionCable: How to use dynamic channels

ActionCable: How to use dynamic channels

Pass a roomId on your subscription creation in javascripts/channels/room.js:

MakeMessageChannel = function(roomId) {
  // Create the new room channel subscription
  App.room = App.cable.subscriptions.create({
    channel: "RoomChannel",
    roomId: roomId
 }, {
@ntamvl
ntamvl / bash_color.md
Created March 7, 2018 07:17
Bash color

Bash color

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
alias ll='ls -al'
@ntamvl
ntamvl / fixed_some_errors_when_install_amber_on_macos.md
Last active February 21, 2024 11:12
Fixed some errors when install amber on macOS

Fixed some errors when install amber on macOS

Install all required libraries for Crystal on macOS

xcode-select --install
brew install \
  bdw-gc \
  gmp \
  libevent \
 libxml2 \
@ntamvl
ntamvl / fixing-npm-permissions.md
Created February 24, 2018 06:06
NPM: How to Prevent Permissions Errors

NPM: How to Prevent Permissions Errors

This section does not apply to Microsoft Windows. This chapter will be updated to address Windows in the near future.

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, it will be a hidden directory on your home folder.

Back-up your computer before you start.

Make a directory for global installations:

@ntamvl
ntamvl / how-to-implement-a-callback-in-ruby.md
Last active February 21, 2024 11:12
How to implement a “callback” in Ruby?

How to implement a “callback” in Ruby?

This "idiomatic block" is a very core part of everyday Ruby and is covered frequently in books and tutorials. The Ruby information section provides links to useful [online] learning resources.

The idiomatic way is to use a block:

def x(z)
  yield z   # perhaps used in conjunction with #block_given?
end
x(3) {|y| y*y} # => 9
@ntamvl
ntamvl / Check_status_ethereum_download.md
Last active February 21, 2024 11:12
Check status ethereum download

Check status ethereum download

Create bash file check_status.sh with below content:

geth --exec 'var s = eth.syncing; console.log("\n------------ GETH SYNCING PROGRESS\nprogress: " + (s.currentBlock/s.highestBlock*100)+ " %\nblocks left to parse: "+ (s.highestBlock-s.currentBlock) + "\ncurrent Block: " + s.currentBlock + " of " + s.highestBlock)' attach http://127.0.0.1:8545

# source: https://ethereum.stackexchange.com/questions/394/how-can-i-find-out-what-the-highest-block-is

Remember change mode execute for this file: