Skip to content

Instantly share code, notes, and snippets.

View powerdefy's full-sized avatar

Peerachai Deesongkram powerdefy

View GitHub Profile
@powerdefy
powerdefy / Main.scala
Created April 24, 2022 11:23 — forked from jpallari/Main.scala
Ways to pattern match generic types in Scala
object Main extends App {
AvoidLosingGenericType.run()
AvoidMatchingOnGenericTypeParams.run()
TypeableExample.run()
TypeTagExample.run()
}
class Funky[A, B](val foo: A, val bar: B) {
override def toString: String = s"Funky($foo, $bar)"
}
@powerdefy
powerdefy / result.txt
Last active June 22, 2021 08:45
small pdf local test
LOCAL TEST: MacOS MBP 2019: 2.4 GHz, 16 GB
APPLICATIONS: GHZ (LOCAL) -> NGINX (DOCKER) -> (2 GRPC SERVERS LOCAL)
ARGS: -c 10 -n 10000 --rps 40
WORKERS : 2
PDF SIZE: : 86KB
SSL to NGINX : ON
SSL to GRPC SERVER : ON
TargetRPS : 40
------------------------------------------------------------------------
# Generate CA key:
openssl genrsa -des3 -out ca.key 4096
# Generate CA certificate:
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
# Generate server key:
openssl genrsa -des3 -out server.key 4096
# Generate server signing request:
@powerdefy
powerdefy / docker-compose.yml
Last active June 15, 2021 04:55
Connect to a FortiNet VPNs through docker
version: "3.7"
services:
forticlient:
image: c0d1um/docker-forticlient
environment:
- VPNADDR=$VPNADDR
- VPNUSER=$VPNUSER
- VPNPASS=$VPNPASS
- VPNTIMEOUT=$VPNTIMEOUT
set -e
brew install softhsm opensc # install softhsm2
# clear all tokens
rm -rf /usr/local/var/lib/softhsm/tokens/*
cat > private.pem <<EOL
Bag Attributes
localKeyID: A0 14 BC 15 70 06 95 7D CD A0 48 F8 3B EC CC D3 C6 42 DE FC
Key Attributes: <No Attributes>
import csv
import datetime
import os
import pathlib
import xmltodict
xml_path = "xml_file_uploads/2021/"
pdf_path = "pdf_file_uploads/2021/"
output_path = "map.csv"

NATS RR Protocal (Draft)

Request

fields

  • name: name of the function you want to execute
  • args: arguments of the function
  • kwargs: keyword arguments of the function

example

Date Options

If the time is: 2014-06-01 01:37:35 UTC

Time Option New Time
@RemindMe One Year 2015-06-01 01:37:35 UTC
@RemindMe 3 Months 2014-09-01 01:37:35 UTC
@RemindMe One Week 2014-06-08 01:37:35 UTC
@RemindMe 1 Day 2014-06-02 01:37:35 UTC
# from https://web.facebook.com/groups/ThaiPGAssociateSociety/permalink/1683383838539545/
def binarySearch (A, l, r):
if r >= l:
k = l + (r - l) // 2
if k + 1 == A[k]:
return k
elif k + 1 > A[k] :
@powerdefy
powerdefy / GCR.md
Last active December 16, 2020 18:34