Skip to content

Instantly share code, notes, and snippets.

Avatar
🎹
Playing

Dong Nguyen ndaidong

🎹
Playing
View GitHub Profile
@ndaidong
ndaidong / install-deno.sh
Created Apr 23, 2021
Install Go, Node, Deno on Endeavour, Debian, Fedora
View install-deno.sh
#!/bin/bash
export DENO_VERSION=1.9.0
export DENO_DOWNLOAD_URL=https://github.com/denoland/deno/releases/download/v$DENO_VERSION/deno-x86_64-unknown-linux-gnu.zip
export DENO_INSTALL=/opt/deno
export PATH=$DENO_INSTALL/bin:$PATH
sudo mkdir $DENO_INSTALL
sudo chown -R ${USER} $DENO_INSTALL
@ndaidong
ndaidong / sslcheck.py
Created Apr 23, 2021
Check SSL certificate expiration with Python
View sslcheck.py
#!/usr/bin/env python3
import ssl
import OpenSSL # pip install pyopenssl
from datetime import datetime
def get_cert_expiration(domain):
cert = ssl.get_server_certificate((domain, 443))
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert)
View Gitea - Activity logs
2021/04/22 13:20:12 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)
2021/04/22 13:20:12 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)
2021/04/22 13:20:12 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)
2021/04/22 13:20:12 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)
2021/04/22 13:20:12 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)
2021/04/22 13:20:12 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHe
View gitea-access.log
This file has been truncated, but you can view the full file.
10.1.0.25:52296 - haond [19/Apr/2021:23:57:45 +0700] "GET /user/events HTTP/1.1" 200 1059 "https://our.domain.com/js/eventsource.sharedworker.js\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36"
10.1.0.25:44806 - huylv [19/Apr/2021:21:01:11 +0700] "GET /user/events HTTP/1.1" 200 36830 "https://our.domain.com/js/eventsource.sharedworker.js\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
10.1.0.25:53328 - huylv [20/Apr/2021:00:05:25 +0700] "GET /cp-baubang/ql-kcb-csxh HTTP/1.1" 200 67443 "\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
10.1.0.25:53340 - huylv [20/Apr/2021:00:05:27 +0700] "GET /api/v1/repos/cp-baubang/ql-kcb-csxh/issues/374 HTTP/1.1" 404 102 "\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
View gitea-activity.log
2021/04/20 00:05:32 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:64)
2021/04/20 00:05:32 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:64)
2021/04/20 00:05:32 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:64)
2021/04/20 00:05:32 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:64)
2021/04/20 00:05:32 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:64)
2021/04/20 00:05:32 ...c/net/http/server.go:3139:logf() [I] http: superfluous response.WriteHe
@ndaidong
ndaidong / app.ini
Last active Apr 22, 2021
Gitea app.ini - Updated
View app.ini
APP_NAME = Gitea
RUN_USER = git
RUN_MODE = prod
[oauth2]
JWT_SECRET = PBjJWPydwCQA...
[security]
INTERNAL_TOKEN = eyJhbGciOi...
INSTALL_LOCK = true
@ndaidong
ndaidong / Setup gitea.md
Last active Apr 20, 2021
How we setup gitea?
View Setup gitea.md
  • Gitea: 1.14.0
  • Git: 2.29.2
  • Go: 1.16.3
  • Redis: 5.0.3
  • OS: Debian 10.9, kernel 5.10.19

(We place the programs within /workspace and store data within /storage)

sudo mkdir -p /workspace/runtime/custom/conf
View simple-git-branching-model.md

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@ndaidong
ndaidong / ip_count_from_netmask.py
Last active Oct 8, 2019
Counting number of IP belongs to a subnetmask
View ip_count_from_netmask.py
#!/usr/bin/env python3
from functools import reduce
from collections import Counter
def ip_count(netmask):
tmp = list(map(lambda x: bin(int(x)), netmask.split('.')))
arr = list(reduce(lambda x, y: x + y, tmp))
counter = Counter(arr)
return counter['1']
@ndaidong
ndaidong / install-go.sh
Last active Apr 23, 2021
Install Go on Endeavour, Debian, Fedora
View install-go.sh
#!/bin/bash
export GO_VERSION=1.16.3
export GO_DOWNLOAD_URL=https://storage.googleapis.com/golang/go$GO_VERSION.linux-amd64.tar.gz
export GOROOT=/opt/go
export GOPATH=$GOROOT/packages
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
sudo mkdir $GOROOT