Skip to content

Instantly share code, notes, and snippets.

View naviocean's full-sized avatar
🌴
On vacation

Duong Le naviocean

🌴
On vacation
View GitHub Profile
@naviocean
naviocean / readme.rmd
Created March 7, 2023 09:12 — forked from ahallora/readme.rmd
How to make SSL work on Microsoft Azure
##How to make SSL work on Microsoft Azure
##### Microsoft Azure requires a password-protected PFX file (containing the public key for your domain including any and all intermediate CA certs) in order to support HTTPS (TLS - SSL) support on your Azure hosted websites. Here's how to get it working with certificates from GeoTrust / RapidSSL (and others too probably).
__1) Create CSR__
Create a CSR-file and private key with OpenSSL and upload it to your CA:
```
openssl req -new -nodes -keyout yourprivatekey.key -out server.csr -newkey rsa:2048
```
@naviocean
naviocean / sssh
Last active November 26, 2022 15:22 — forked from yuki777/sssh
aws ecs login script
#!/bin/bash
############################################################################
# Copyright 2022 Yuki Adachi https://github.com/yuki777
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@naviocean
naviocean / zfs-docker.md
Created November 14, 2022 15:09 — forked from AnatomicJC/zfs-docker.md
ZFS and Docker

Create a dedicated ZFS docker pool with deduplication disabled in case of dedup enabled on your system:

zfs create -o mountpoint=/var/lib/docker -o dedup=off rpool/docker

Sometimes, you don't want ZFS for docker storage. ZFS can be sadly quite painful with Docker in Docker and similar scenarios. It might be best to avoid the problem by creating a volume in your ZFS pool, formatting that volume to ext4, and having docker use "overlay2" on top of that, instead of "zfs".

zfs create -s -V 30G rpool/docker

mkfs.ext4 /dev/zvol/rpool/docker

@naviocean
naviocean / tokenPriceApi.js
Created October 24, 2022 15:29 — forked from Linch1/tokenPriceApi.js
Retrive the price of any bsc token from it's address without using external service like poocoin/dextools
let pancakeSwapAbi = [
{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsOut","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},
];
let tokenAbi = [
{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},
];
const Web3 = require('web3');
/*
Required Node.js
@naviocean
naviocean / nodejs-cicd-github-actions.md
Created June 14, 2022 08:09 — forked from danielwetan/nodejs-cicd-github-actions.md
Deploy Node.js to VPS using Github Actions

Deploy Node.js to VPS using Github Actions

Steps to deploy Node.js to VPS using PM2 and Github Actions

1. Clone repo to VPS folder

@naviocean
naviocean / docker-cleanup
Created September 10, 2021 06:32 — forked from wdullaer/docker-cleanup
Cleanup unused Docker images and containers
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'
@naviocean
naviocean / nginx-tuning.md
Created August 31, 2021 15:35 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@naviocean
naviocean / mongodump.md
Last active March 16, 2021 09:42
mongodump and mongorestore with Docker

With Docker

With docker, pseudo-tty allocation is deactivated by default, but the -i (interactive) option is required with the restore command.

mongodump

  • No Auth : docker exec <mongodb container> sh -c 'mongodump --archive' > db.dump

  • Authenticated : docker exec <mongodb container> sh -c 'mongodump -d <database> -u <user> -p <password> --archive' > db.dump

mongorestore

  • No Auth : docker exec -i sh -c 'mongorestore --archive' &lt; db.dump
@naviocean
naviocean / get_n_params.py
Created November 17, 2020 07:46
Check the number of parameters of a model
# reference
# https://discuss.pytorch.org/t/how-do-i-check-the-number-of-parameters-of-a-model/4325
def get_n_params(model):
pp=0
for p in list(model.parameters()):
nn=1
for s in list(p.size()):
nn = nn*s
pp += nn
@naviocean
naviocean / git_large_file.md
Created September 14, 2020 07:36
Fixing the “GH001: Large files detected. You may want to try Git Large File Storage.”

Fixing the “GH001: Large files detected. You may want to try Git Large File Storage.”

I just migrated my repositories from BitBucket to GitHub but, suddenly, I received an interesting error when I tried to push a repo with some large files inside.

remote: error: GH001: Large files detected. You may want to try Git Large File Storage — https://git-lfs.github.com.
remote: error: Trace: b5116d865251981c96d4b32cdf7ef464
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File fixtures/11_user_answer.json is 131.37 MB; this exceeds GitHub’s file size limit of 100.00 MB