Skip to content

Instantly share code, notes, and snippets.

View loctv's full-sized avatar

Loc Truong loctv

  • kiuglobal.com
  • Ha Noi, Viet Nam
View GitHub Profile
@loctv
loctv / http_streaming.md
Created February 22, 2017 04:43 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@loctv
loctv / latency.txt
Created April 7, 2017 03:39 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@loctv
loctv / iterm2-solarized.md
Created November 7, 2017 02:57 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

WITH recursive dep_tree AS (
SELECT mdl0.id, mdl0.name, NULL::integer, 1 AS level, array[mdl0.id] AS path_info
FROM ir_module_module mdl0
WHERE name = 'sale' -- state here the child module
UNION ALL
SELECT (SELECT mdl1.id FROM ir_module_module mdl1 WHERE mdl1.name = c.name), rpad('', p.level * 1, '_') || c.name, c.module_id, p.level + 1, p.path_info||c.id
FROM ir_module_module_dependency c
JOIN dep_tree p ON c.module_id = p.id
)
SELECT level, name
@loctv
loctv / Event-stream based GraphQL subscriptions.md
Created September 24, 2018 14:44 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@loctv
loctv / example_host.conf
Created July 23, 2019 10:29 — forked from rm3nchaca/example_host.conf
Simple script for blocking attacker bots with nginx and a lua script
server {
listen 80;
server_name example.com;
root /www/example;
access_by_lua 'denyip()'; #check error counter
error_page 400 404 405 406 = /404.html;
location = /404.html {
set $inc 1; #this is useful for blocking website scanners
set_by_lua $err 'incerror()' $inc;
@loctv
loctv / wget-page.sh
Created July 24, 2019 08:17 — forked from alphapapa/wget-page.sh
Archive web pages with wget, optionally compressing with tar
#!/bin/bash
# * Defaults
compression=xz
subdir="web"
# * Functions
function debug {

Keybase proof

I hereby claim:

  • I am loctv on github.
  • I am loctv (https://keybase.io/loctv) on keybase.
  • I have a public key ASCpVx1Hoju78aE2Qjavn1B93pDEFgpy5FmPnys6vyDTUAo

To claim this, I am signing this object:

@loctv
loctv / hyperjs.md
Created November 22, 2019 02:46 — forked from raftheunis87/hyperjs.md
Hyper.js + Hyper.js Plugins + ZSH + Starship + Fira Code + Dark Theme - (macOS)

Hyper.js

@loctv
loctv / odoo_calculate_workers.sh
Created November 21, 2020 03:37
Analyzes the characteristics of the server and helps calculate the number of workers and memory for each
#!/bin/bash
# CONST 1GB
CONST_1GB="1024*1024*1024"
# VARIABLE WORKERS
CMD_W=0