Skip to content

Instantly share code, notes, and snippets.

@YongmingZhao
YongmingZhao / steps.txt
Last active December 15, 2021 13:54
Setting up ubuntu on virtual box
1.Enable sharing folders:
sudo apt-get install virtualbox-guest-additions-iso
sudo mount -o loop /usr/share/virtualbox/VBoxGuestAdditions.iso /media/
cd /media
sudo ./VBoxLinuxAdditions.sh
sudo reboot
sudo adduser jeff vboxsf
2.Enlarge partitions:
@YongmingZhao
YongmingZhao / regex.txt
Last active March 28, 2022 19:00
JS regex
^CREATE[\s\w`\(\n\),'\u00000-\uFFFFF-]*;$ //match sql
^(\s)*$\n //match empty line
@YongmingZhao
YongmingZhao / download.html
Created March 2, 2022 10:49
Download a file with authentication
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
</style>
<script src="https://code.jquery.com/jquery-3.6.0.js"
integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script>
@YongmingZhao
YongmingZhao / clone.sh
Last active March 30, 2022 12:53
Git clone a repository and push to another
git clone -b v4.1.2-beta --depth 1 https://github.com/poanetwork/blockscout
cd blockscout
git remote rename origin upstream
git remote add origin [email protected]:YongmingZhao/blockscout.git
git branch -f master HEAD
git checkout master
git fetch --unshallow upstream
git push origin master
@YongmingZhao
YongmingZhao / build_erlang_ssl.sh
Created March 30, 2022 10:28
Compile openssl and Erlang/OTP
#!/bin/bash
cd openssl-3.0.2
./Configure shared --prefix=`pwd`/target --openssldir=`pwd`/target
make
make install
cd ../blockscout
export KERL_CONFIGURE_OPTIONS=--without-javac --with-ssl=/somepath/openssl-3.0.2/target
asdf install erlang 24.2
@YongmingZhao
YongmingZhao / libsecp256k1.md
Created April 7, 2022 10:55
Compile libsecp256 with blockscout
  • Clean old build files: rm -rf _build deps; mix deps.clean --all
  • Download deps: mix deps.get
  • Install tools and other libs: sudo port install gmp libtool
  • Try build libsecp256k1: cd deps/libsecp256k1/c_src/secp256k1; aclocal; autoconf; cd ..; ./build_deps.sh
  • Try build blockscout: cd blockscout; mix do deps.get, local.rebar --force, deps.compile, compile
  • If gmp.h not found, then modify Makefile: vi deps/libsecp256k1/Makefile, add following CFLAGS += -I /opt/local/include -L /opt/local/lib
  • Rebuild blockscout: mix do deps.get, local.rebar --force, deps.compile, compile
@YongmingZhao
YongmingZhao / build.md
Last active April 17, 2022 14:10
Build Metamask on Mac
  • Prepare a working directory:

    (Optional) nvm is conflict with asdf, if nvm is installed, deactive it

    nvm unload
    rm -rf ~/.nvm # important, further steps will scan this path, remove or rename it

    Create a working directory:

mkdir metamask

@YongmingZhao
YongmingZhao / mysql.md
Created May 9, 2022 19:49
Cent OS Mysql

rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum install mysql-server

  1. log-in your mysql via terminal as "root" --> mysql -uroot -p
  2. CREATE USER 'toor123'@'%' IDENTIFIED BY 'your-password';
  3. GRANT ALL PRIVILEGES ON . TO 'toor123'@'%';flush privileges;
  4. Open mysql's configuration file: vi /etc/my.cnf
  5. Append the following directive into the [mysqld] section: bind-address=192.168.1.80 (server's address)
  6. Make sure line "skip-networking" is commented
  7. Store your changes and restart Mysqld: systemctl start|stop|status mysqld
  8. firewall-cmd --zone=public --add-port=3306/tcp --permanent
@YongmingZhao
YongmingZhao / nginx.md
Created January 30, 2023 11:01
Nginx https bridge

Create a self-signed ssl server

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt

Add config

ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;