Skip to content

Instantly share code, notes, and snippets.

View dhcmrlchtdj's full-sized avatar

H11 dhcmrlchtdj

View GitHub Profile
@dhcmrlchtdj
dhcmrlchtdj / logger.js
Last active August 27, 2022 15:07
nginx log in JSON with njs
function logJSON(r) {
const v = r.variables
return JSON.stringify({
time: v.time_iso8601,
id: v.request_id,
latency: Number(v.request_time),
remote: r.remoteAddress,
request: {
http_version: r.httpVersion,
protocol: v.scheme,
// http://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=64&pc=1#code/PTAEjgVQjdMCldF-FQHU0Fxyho+QFAlIN0VBrcoTu1AWaoBD-8gI36DCcoM+BgL2aCwmoELmgIW6DLfoCHmgkP+D6coPRmgAHKDsFg0DKCYDAXdGEDyyoA3lQIAMgMATJgGH-ATdEMuoAEIB7AB4AeAEYBDAM4BTAHyhAMSoadu4wFd9lwFcqgKjlAskZr9OgPpGzMVs9AItQbz9QhUBGHS4pIK09R2dQSUAEI1AfbX8TUxiueSCAWhKgwAG5QAk5QGvlTNyFQEAY0ABLADtjABdDFoBjU1BALE162NrAjEALCMAG50QFQFLjQDZTEb6GQAZ1QE7TBUB75UBTuUBrDVBk4tKMCkA4uVAAa012gBtW0EBpOUBvHwZK5pbgTQd2oO2mQAgVBAMZCABW1AKbmwkAx5EKQBDyvA3qB5ApACvxgD21QA8CqBPu1QPFDkVUKh2gBPAAOfVCoAAvPt2gAnVoAc1AAB9QC0HABbfSmWmE0l9ZJUmn0loMgkYQCf2qi0VJQN1NEUAG6GeldXp8slyzQ5MxCgAUAEoqZZQhq+vLfILqYbjfsnOKwBLYfItS06YYlSqmmrTGbXe6dX1rQATQydABcdv0RsplnZ12ufvlbtphktTn1oYjixjcYcCaC3VyACYk5oU2nQsXM2HDJHkrnFmWK+n9NWQ7XI6FGwcgq1Paqer7iZrWoHfAANGvZ7u200jvpj5KT6d1qM9+14gnJjqgABmAEZIxaKdbGwAGVA77F74vH7VW0A22OgADkr+35d37VMHSPWsDIVbyvL9sR-Do7wAx9D1ADAABV+TfE9clfZpjDZK5QBMYwmgZFpDH0a4+naTRQAXJCHycD8txAtobwAZnvFtTyfLM1wbW140Ta99wAFiYgNHz1Niu1yRsuM-OiyN-dpGP9VNAOpPdeNo78ZP4+S02g+jYLABDNVfZMA1CVCmnQlp
@dhcmrlchtdj
dhcmrlchtdj / proxy.ts
Last active November 18, 2017 06:13
HTTP proxy in typescript. client --HTTP_PROXY--> local_proxy --HTTP_PROXY--> remote_proxy --> server
import * as HTTP from 'http';
import * as URL from 'url';
import * as NET from 'net';
import * as ProxyAgent from 'proxy-agent';
export function createProxy(proxyURL: string): HTTP.Server {
const agent: HTTP.Agent = new ProxyAgent(proxyURL);
const proxyURLObj = URL.parse(proxyURL);
const proxyServer = new HTTP.Server();
@dhcmrlchtdj
dhcmrlchtdj / hackerrank_helper.ml
Last active May 27, 2018 04:06
OCaml helper for hackerrank
(* $ ocaml str.cma template.ml *)
module H = struct
module P = Pervasives
let split s : string list = Str.split (Str.regexp " +") s
let seq len = Array.make len 0 |> Array.to_list
let rint () : int = P.read_int ()
@dhcmrlchtdj
dhcmrlchtdj / kernel.log
Created January 11, 2017 07:37
leap second
Jan 1 07:59:59 hostname kernel: Clock: inserting leap second 23:59:60 UTC
@dhcmrlchtdj
dhcmrlchtdj / yarn_node_lts.sh
Last active January 17, 2017 09:43
yarn && node@6
$ ### install
$ brew install yarn
๐Ÿบ /usr/local/Cellar/node/7.4.0: 4,129 files, 46.3M
๐Ÿบ /usr/local/Cellar/yarn/0.18.1: 5,639 files, 18.2M
$ brew unlink node
Unlinking /usr/local/Cellar/node/7.4.0... 7 symlinks removed
$ brew install node@6
@dhcmrlchtdj
dhcmrlchtdj / vimrc.vim
Last active November 14, 2017 20:30
vimrc for ocaml/reason. (deoplete + merlin)
filetype plugin indent off
let g:dein#types#git#clone_depth = 1
set runtimepath+=~/.config/nvim/bundle/repos/github.com/Shougo/dein.vim/
call dein#begin(expand('~/.config/nvim/bundle'))
call dein#add('Shougo/dein.vim')
call dein#add('Shougo/deoplete.nvim')
let g:deoplete#enable_at_startup = 1
let g:deoplete#file#enable_buffer_path = 1

๐€ | ๐ | ๐‚ | ๐ƒ | ๐„ | ๐… | ๐† | ๐‡ | ๐ˆ | ๐‰ | ๐Š | ๐‹ | ๐Œ | ๐ | ๐Ž | ๐ | ๐ | ๐‘ | ๐’ | ๐“ | ๐” | ๐• | ๐– | ๐— | ๐˜ | ๐™

๐š | ๐› | ๐œ | ๐ | ๐ž | ๐Ÿ | ๐  | ๐ก | ๐ข | ๐ฃ | ๐ค | ๐ฅ | ๐ฆ | ๐ง | ๐จ | ๐ฉ | ๐ช | ๐ซ | ๐ฌ | ๐ญ | ๐ฎ | ๐ฏ | ๐ฐ | ๐ฑ | ๐ฒ | ๐ณ

๐ด | ๐ต | ๐ถ | ๐ท | ๐ธ | ๐น | ๐บ | ๐ป | ๐ผ | ๐ฝ | ๐พ | ๐ฟ | ๐‘€ | ๐‘ | ๐‘‚ | ๐‘ƒ | ๐‘„ | ๐‘… | ๐‘† | ๐‘‡ | ๐‘ˆ | ๐‘‰ | ๐‘Š | ๐‘‹ | ๐‘Œ | ๐‘

๐‘Ž | ๐‘ | ๐‘ | ๐‘‘ | ๐‘’ | ๐‘“ | ๐‘” | ๐‘– | ๐‘— | ๐‘˜ | ๐‘™ | ๐‘š | ๐‘› | ๐‘œ | ๐‘ | ๐‘ž | ๐‘Ÿ | ๐‘  | ๐‘ก | ๐‘ข | ๐‘ฃ | ๐‘ค | ๐‘ฅ | ๐‘ฆ | ๐‘ง | ๐šค | ๐šฅ

๐‘จ | ๐‘ฉ | ๐‘ช | ๐‘ซ | ๐‘ฌ | ๐‘ญ | ๐‘ฎ | ๐‘ฏ | ๐‘ฐ | ๐‘ฑ | ๐‘ฒ | ๐‘ณ | ๐‘ด | ๐‘ต | ๐‘ถ | ๐‘ท | ๐‘ธ | ๐‘น | ๐‘บ | ๐‘ป | ๐‘ผ | ๐‘ฝ | ๐‘พ | ๐‘ฟ | ๐’€ | ๐’

@dhcmrlchtdj
dhcmrlchtdj / fstab
Last active September 28, 2016 08:14
#
# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
none /dev/pts devpts defaults 0 0
none /dev/shm tmpfs defaults 0 0
#/dev/cdrom /media/cd auto ro,user,noauto,unhide 0 0
#/dev/dvd /media/dvd auto ro,user,noauto,unhide 0 0
#/dev/fd0 /media/fl auto user,noauto 0 0
# forward f port remote-port remote-host
# forward c port remote-port remote-host
forward() {
case "$1" in
"f") ssh -v -O forward -R $3:localhost:$2 $4 ;;
"c") ssh -v -O cancel -R $3:localhost:$2 $4 ;;
esac
}