Skip to content

Instantly share code, notes, and snippets.

View socheatsok78's full-sized avatar
🖖
༼ つ ◕_◕ ༽つ is having a baby

Socheat Sok socheatsok78

🖖
༼ つ ◕_◕ ༽つ is having a baby
View GitHub Profile
/**
* A backward-compatible for FileReader: readAsBinaryString() method
* @param arrayBuffer {ArrayBuffer}
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsBinaryString
*/
function readAsBinaryString (arrayBuffer) {
const binary = []
const arrayBufferView = new Uint8Array(arrayBuffer)
for (let i = 0; i < arrayBufferView.length; i++) {
binary.push(String.fromCharCode(arrayBufferView[i]))
@socheatsok78
socheatsok78 / flush-iptables.sh
Created November 7, 2024 10:20 — forked from mrclay/flush-iptables.sh
Flush IP tables and restart docker
#!/bin/bash
# Script is needed because my default firewall rules are messed up and after
# every restart, docker containers can't make connections to the host, notably
# preventing debuggers like xdebug from attaching.
# If networking fails in your containers but works in others, rm and re-create the
# docker network that container is bound to.
set -euo pipefail
@socheatsok78
socheatsok78 / README.md
Last active October 7, 2024 00:39
Add a simple Dark Mode toggle to any site without using extensions.

About

Add a simple Dark Mode toggle to any site without using extensions.

Bookmarklet

You can add this code to any page using the following bookmarklet:

javascript: (function (d) { sl = d.createElement('style'), s = d.createElement('script'); sl.innerHTML = '.darkmode-layer, .darkmode-toggle { z-index: 500; }'; d.head.appendChild(sl); s.onload = function () { new Darkmode({ saveInCookies: false, label: '🌓', right: 'unset', left: '32px' }).showWidget(); }; s.src = '//cdn.jsdelivr.net/npm/[email protected]/lib/darkmode-js.min.js'; d.head.appendChild(s); })(document)
services:
my-container:
networks:
# Attach the service to the traefik-public network
traefik-public:
deploy:
labels:
# Enable Traefik for this service
- traefik.enable=true
- traefik.http.routers.my-container.rule=Host(`example.com`)
@socheatsok78
socheatsok78 / abtostr.js
Created April 5, 2024 06:09
A browser implementation for String <-> ArrayBuffer
/*
Convert an ArrayBuffer into a string
from https://developer.chrome.com/blog/how-to-convert-arraybuffer-to-and-from-string/
*/
function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
}
@socheatsok78
socheatsok78 / KUBERNETES_SETUP.md
Created March 29, 2024 03:48 — forked from dPacc/KUBERNETES_SETUP.md
Setup Kubernetes Cluster on premise using kubeadm

Setup Kubernetes Cluster On-Premise using kubeadm

Why would you do this?

  • You own your bare metal infrastructure.
  • You want to take advantage of Kubernetes.
  • You do not wish to migrate your application to the cloud

Why it will not always suit your needs?

@socheatsok78
socheatsok78 / trusted_certificate_stores_on_linux_os_and_applications.md
Created November 13, 2023 08:57 — forked from CMCDragonkai/trusted_certificate_stores_on_linux_os_and_applications.md
SSL/TLS: Trusted Certificate Stores on Linux Operating Systems and Applications

Trusted SSL/TLS Certificate Stores on Linux Operating Systems and Applications

The SSL/TLS store location is not standardised across operating systems or even Linux distros. It could be anywhere in:

  • /etc/ssl/certs
  • /etc/pki/tls/certs/ca-bundle.crt
  • /etc/ssl/certs/ca-bundle.crt
  • /etc/pki/tls/certs/ca-bundle.trust.crt
@socheatsok78
socheatsok78 / docker-swarm-architecture.md
Created September 27, 2023 02:02 — forked from scyto/docker-swarm-architecture.md
My Docker Swarm Architecture
@socheatsok78
socheatsok78 / consoleWithNoSource.js
Last active September 13, 2023 05:44
Hide source of Log messages in browser console
function consoleWithNoSource(...params) {
setTimeout(console.log.bind(console, ...params));
}
consoleWithNoSource("Helloo....!")