Skip to content

Instantly share code, notes, and snippets.

View socheatsok78's full-sized avatar
πŸ––
ΰΌΌ ぀ β—•_β—• ༽぀ is having a baby

Socheat socheatsok78

πŸ––
ΰΌΌ ぀ β—•_β—• ༽぀ is having a baby
View GitHub Profile
@socheatsok78
socheatsok78 / GoConcurrency.md
Created October 6, 2022 04:23 — forked from rushilgupta/GoConcurrency.md
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

@socheatsok78
socheatsok78 / headache.md
Created August 22, 2022 02:31 — forked from pbrisbin/headache.md
ZSH startup file headaches

Default behavior dictates the following order for ZSH startup files:

  • /etc/zshenv
  • ~/.zshenv
  • /etc/zprofile (if login shell)
  • ~/.zprofile (if login shell)
  • /etc/zshrc (if interactive)
  • ~/.zshrc (if interactive)
  • /etc/zlogin (if login shell)
  • ~/.zlogin (if login shell)
@socheatsok78
socheatsok78 / unixhttpc.go
Created August 3, 2022 15:15 — forked from teknoraver/unixhttpc.go
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@socheatsok78
socheatsok78 / README-setup-tunnel-as-systemd-service.md
Created July 22, 2022 08:53 — forked from drmalex07/README-setup-tunnel-as-systemd-service.md
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
if (typeof registerPaint === 'function') {
class DotGridWorket {
static get inputProperties() {
return ['--dot-size', '--dot-spacing', '--dot-color'];
}
parseProps(props) {
const dotSize = props.get('--dot-size');
const dotSpacing = props.get('--dot-spacing');
const dotColor = props.get('--dot-color');
{
"basics": {
"name": "Socheat Sok",
"label": "Senior Software Developer",
"picture": "https://avatars.githubusercontent.com/u/4363857?v=4",
"email": "alex@socheat.net",
"website": "https://socheat.dev",
"summary": "I'm a Full-Stack Software Developer. I got my bachelor degree on Management Information System at SETEC Institute. I was previously working at Open Institute, my work focused on inproving User Experience and optimizing website performance using new standard of frontend development by switching the existing code base of using jQuery to using modern JavaScript libraries such as VueJS and Webpack. I also work with the backend team to improve performance of the backend service as well by using standard Eloquent and ORM for handling database transaction instead of using raw SQL queries.",
"location": {
"address": "292 St",
@socheatsok78
socheatsok78 / generate-gradient-string.js
Created February 17, 2022 04:27
Vue.js style gradient string
var fs = require('fs')
var gradientString = require('gradient-string')
var out = gradientString([
{ color: '#42d392', pos: 0 },
{ color: '#42d392', pos: 0.1 },
{ color: '#647eff', pos: 1 }
])('Vue.js - The Progressive JavaScript Framework')
var data = out.replace(/\x1B/g, '\\x1B')
@socheatsok78
socheatsok78 / go-arch.md
Created February 6, 2022 09:33 — forked from zfarbp/arch.md
Golang - Building Executables for Different Architectures

Golang - Building Executables for Different Architectures

env GOOS=target-OS GOARCH=target-architecture go build package-import-path

# Example
env GOOS=darwin GOARCH=amd64 go build
env GOOS=darwin GOARCH=amd64 go build main.go
env GOOS=darwin GOARCH=amd64 go build github.com/zoo/york/foo/bar
@socheatsok78
socheatsok78 / golang-tls.md
Created February 4, 2022 02:03 — forked from 6174/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" β‰₯ 2048-bit
openssl genrsa -out server.key 2048
    
# Key considerations for algorithm "ECDSA" β‰₯ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key