Skip to content

Instantly share code, notes, and snippets.

@rajinwonderland
rajinwonderland / memorySizeOf.js
Created March 4, 2020 01:06
Calculate Memory Size of a JS Object
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if (obj !== null && obj !== undefined) {
switch (typeof obj) {
case "number":
bytes += 8;
break;
case "string":
@kekru
kekru / 1-Enable Docker Remote API with TLS client verification.md
Last active January 11, 2024 18:21
Docker Remote API with client verification via daemon.json

Enable Docker Remote API with TLS client verification

Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:

  • CA certificate
  • Server certificate
  • Server key
  • Client certificate
  • Client key

Create certificate files

@noelboss
noelboss / git-deployment.md
Last active April 25, 2024 10:38
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@yosssi
yosssi / go-nginx.md
Last active April 11, 2024 22:07
Go networking performance vs Nginx

1. Nginx

$ wrk -t12 -c400 -d2s http://127.0.0.1:8080
Running 2s test @ http://127.0.0.1:8080
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.71ms    3.16ms  23.05ms   69.17%
    Req/Sec     3.44k     1.98k    7.80k    58.22%
  63697 requests in 2.00s, 17.86MB read
# -*- coding: utf-8 -*-
import socket
import os
print("Connecting...")
if os.path.exists("/tmp/python_unix_sockets_example"):
client = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
client.connect("/tmp/python_unix_sockets_example")
print("Ready.")
print("Ctrl-C to quit.")
@pauloricardomg
pauloricardomg / cors.nginxconf
Last active March 8, 2024 18:31
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {
@tapanpandita
tapanpandita / .gitignore
Created May 11, 2012 12:11
Serving password protected files from Nginx
.*.swp