Skip to content

Instantly share code, notes, and snippets.

🎯
¯\_(ツ)_/¯

Ali Najafizadeh alinz

🎯
¯\_(ツ)_/¯
Block or report user

Report or block alinz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@alinz
alinz / Certificates.go
Created Nov 12, 2019 — forked from Mattemagikern/Certificates.go
Create x509 certificate chain using Golang. Root CA, Designated CA, server CA
View Certificates.go
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"math/big"
@alinz
alinz / sample.sh
Created Nov 12, 2019
OPENSSL encrypt decrypt
View sample.sh
openssl aes-256-cbc -in plain.txt -out plain.enc -k cool
openssl aes-256-cbc -d -in plain.enc -out plain.txt -k cool
@alinz
alinz / PROFILE.MD
Created Nov 7, 2019
Golang Profiling commands
View PROFILE.MD

Prfile

Generate Prfile data

go test -cpuprofile cpu.prof -memprofile mem.prof -bench .

Visual Profile data

View model.ts
export class Model {
constructor(obj: any) {
for (let key in obj) {
this.unmarshal(toCamelCase(key), obj[key])
}
}
marshal(): any {
return Object.keys(this).reduce((obj: any, key: string) => {
obj[toSnakeCase(key)] = toJS(this[key])
@alinz
alinz / Makefile
Created Sep 25, 2019
Compile Zig to WebAssembly and run it in Node.js
View Makefile
build:
zig build-exe --name test.wasm -target wasm32-freestanding --release-small test.zig
View setup react project
// babel js
{
"plugins": [
["react-hot-loader/babel"],
["babel-plugin-root-import"],
[
"import", {
"libraryName": "antd",
"libraryDirectory": "es",
@alinz
alinz / golang_tls_http.go
Created Jul 11, 2019
Share tls config with server and client in golang
View golang_tls_http.go
package main
import (
"bytes"
"crypto/tls"
"crypto/x509"
"io"
"io/ioutil"
"log"
"net/http"
@alinz
alinz / router.go
Created Jul 7, 2019
router with cors
View router.go
import (
"net/http"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/goware/cors"
)
func New() chi.Router {
cors := cors.New(cors.Options{
@alinz
alinz / Fetcher.js
Created Jul 7, 2019
A simple Fetch implementation
View Fetcher.js
const baseURL = process.env.API_ADDR || 'http://localhost/api'
export type Pagination<T> = {
meta: {
total: number
}
data: T
}
export interface Fetcher {
@alinz
alinz / Makefile
Created May 29, 2019
WebAssembly on Node.js
View Makefile
build:
emcc test.c -O3 -s WASM=1 -s EXPORTED_FUNCTIONS='["_add"]' -s SIDE_MODULE=1 -o test.wasm
run:
node index.js
You can’t perform that action at this time.