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 / ethereum-how-can-i-find-out-the-token-balance-of-some-address.md
Last active March 28, 2018 03:28
[Ethereum] How can I find out the ERC20 token balance of some address?

[Ethereum] How can I find out the ERC20 token balance of some address?

My Token Contract

TOKEN CONTRACT ADDRESS: 0x5d96961e2d1b3bcd7e869fa549c79c7f4140adea
TOKEN NAME: BananaCoin
TOKEN SYMBOL: BNC
Contract JSON Interface:
[ { "constant": true, "inputs": [], "name": "name", "outputs": [ { "name": "", "type": "string", "value": "BananaCoin" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "name": "", "type": "uint8", "value": "2" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "", "type": "uint256", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "name": "", "type": "string", "value": "BNC" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant"
@ntamvl
ntamvl / dumping-and-importing-from-to-mysql-in-an-utf-8-safe-way.md
Last active May 28, 2024 08:54
Dumping and importing from/to MySQL in an UTF-8 safe way

Dumping and importing from/to MySQL in an UTF-8 safe way

In a nutshell: to avoid your shell character set from messing with imports, use -r to export and SOURCE when importing. Dumping safely

# Do not do this, since it might screw up encoding
mysqldump -uroot -p database > utf8.dump # this is bad
@ntamvl
ntamvl / ssh-session-auto-reconnect.md
Created December 12, 2017 03:32
ssh session auto reconnect

ssh session auto reconnect

You probably want to put ServerAliveInterval 60 into ~/.ssh/config which doesn't reconnect but ensures that the connection doesn't disconnect when idling.

If you really want to do what you suggested in your question, you can run from your prompt:

$ while true; do ssh myhost; sleep 1; done
@ntamvl
ntamvl / linux-full-metal-backup-using-dd-command.md
Last active February 21, 2024 11:12
[LINUX] Full Metal Backup Using the dd Command

[LINUX] Full Metal Backup Using the dd Command

As with any aspect of Linux, there are myriad ways to do a single task. Everything from your desktop GUI, running a web server, checking logs, and backing up your system. Finding how to do a task that best suits your need can sometimes be a drawn-out process. But, when you’re looking for a tool to handle a bare metal backup, your quest might very well begin and end with the dd command. The dd command is actually a reference to the DD statement from IBM’s Job Control Language and means Data Description. The primary purpose of dd is to convert and copy files. With dd you can easily copy a partition or an entire drive.

The feature list includes:

Backup and restore a partition or entire drive

Copy regions of raw device files

@ntamvl
ntamvl / install-multiple-jdk-on-macos-high-sierra.md
Last active February 21, 2024 11:12
Install Multiple Java Versions on macOS High Sierra

Install Multiple Java Versions on macOS High Sierra

Install Homebrew Cask

On Mac, Homebrew is the de-facto package manager, and Homebrew Cask is the app manager. I’m going to use Cask to install Java 7 and 8.

Install Homebrew Cask first if you haven’t:

brew update
brew tap caskroom/cask
@ntamvl
ntamvl / rails-transactions-complete-guide.md
Created October 23, 2017 04:41
Rails transactions: The Complete Guide (Just for me to learn)

Rails transactions: The Complete Guide (Just for me to learn)

Rails transactions are a way to ensure that a set of database operations will only occur if all of them succeed. Otherwise, they will rollback to the previous state of data.

Our examples will demonstrate it in the most useful scenario for transactions: money transfers. In this case, you only want Ted to receive money if John loses the same money. Basic usage

def transfer_money
 ActiveRecord::Base.transaction do
@ntamvl
ntamvl / ppa-redis-server-4.md
Created October 20, 2017 07:44
PPA redis-server 4

Adding this PPA to your system

You can update your system with unsupported packages from this untrusted PPA by adding ppa:chris-lea/redis-server to your system's Software Sources. (Read about installing)

sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update
sudo apt-get install redis-server

source: https://launchpad.net/~chris-lea/+archive/ubuntu/redis-server

@ntamvl
ntamvl / how-to-install-java-with-apt-get-on-ubuntu-16-04.md
Created October 13, 2017 05:03
How To Install Java with Apt-Get on Ubuntu 16.04

How To Install Java with Apt-Get on Ubuntu 16.04

Prerequisites

To follow this tutorial, you will need:

One Ubuntu 16.04 server.

A sudo non-root user, which you can set up by following the Ubuntu 16.04 initial server setup guide.
@ntamvl
ntamvl / ethereum-dev-mode.md
Created October 4, 2017 08:31 — forked from evertonfraga/ethereum-dev-mode.md
Set up an Ethereum development network in two minutes
@ntamvl
ntamvl / installing-and-updating-gtx-1080-ti-cuda-drivers-on-ubuntu.md
Created September 25, 2017 07:44
Installing and Updating GTX 1080 Ti Drivers / CUDA on Ubuntu

Installing and Updating GTX 1080 Ti Drivers / CUDA on Ubuntu

Add the PPA to apt-get and update the index by running:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update

Now, we use it to install the desired driver versions (as of this writing):