Skip to content

Instantly share code, notes, and snippets.

View nttuyen's full-sized avatar

Nguyen The Tuyen nttuyen

View GitHub Profile
@nttuyen
nttuyen / System Design.md
Created May 4, 2024 08:51 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@nttuyen
nttuyen / bash-pid.md
Created April 30, 2019 04:49 — forked from darth-veitcher/bash-pid.md
Bash Script PID file locking

Pattern below allows for a bash script to be called via, say, cron and check to see if it is already running.

Useful for things like rsync tasks.

PIDFILE=/var/run/myscriptname.pid

if [ -f $PIDFILE ]
then
 PID=$(cat $PIDFILE)
@nttuyen
nttuyen / authorized_keys2
Created February 23, 2019 04:46
authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDJpmTYobc+FrCiruJOF0vqcSQjSfSZ1XvkgI/5ugohCjb/olJQODa/AZYXcmDRrBLA4qc718rG9vEb4+hWuq6J1iQ0Svu+8uheqCFFjgCAzUhrzDYFbE0NhimxMiNekvPcphGXlcUB6wdkcs8w1CpQJJZpMDqOFuhOlkyAaAI8WorJesOl3tGU9OVVMlJY2oGoNs2ghAbiQzkgl9V9P6b0S2xknlFXD5Y2JFgPOAPRlqtUERY+bsIWl0RrY/IoiAB6K3oCgNr5QsMVKj683tRV6qAfqlwkKtWAXc/BCXJpvs+sj0xCnFabTK+Gp6YxQtec+eDsicLY/ZKp1aMTSfh28YQ/rCcV304KAm1EKNS+zLAI+0ib/7G5ZuE3fYU5f9LwFyYLwJxVfumwOnupcaAn1+LuT0u6lyueHCkenmCA3srbyMlyqKah47zC5WAE0Vbcd40BM689vNDqW/OSOY8VVeqkdkEwT5H8yv9IbwuHsvVKcIjlANAR9lI/vGCs/0Spj5S1HGw/tz+a8H/foHsfIr8Dyt1y04yMmbpzUHTbNlpAWGeCRRIiKUd0oFyQNzIK8A+7exqYvGRWhPFRVcUFwRbpho3G5XbuMaJkIlxtXcW+bo+Q99G7DHEPUCaZ2ExXTg5MHsxyfT7FMEVwS1qSDBB5QpDejXKJj2UDKtcbww== bastillion@global_key
#!/bin/bash
#nttuyen
USER_ID=47054
cache_file=/tmp/key_cache
function dl_keys {
curl -m 10 -sf https://gitlab.com/api/v4/users/$1/keys | jq -r '.[].key'
}
@nttuyen
nttuyen / mysql-docker.sh
Created April 8, 2017 08:14 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@nttuyen
nttuyen / PDOSession.php
Created June 17, 2016 02:16
session handler
<?php
/**
* PDO Session Handler
* @author Daniel15 <dan.cx>
*
* modificata da carlo@chierotti.net
* per gestire la scadenza della sessione
*
* testata in PHP53, se si passa a PHP54 si potrebbe utilizzare
@nttuyen
nttuyen / TestUpdateLayout
Created October 8, 2013 07:18
TestUpdatelayout
public void testUpdateLayout() {
PageData page = createPage(createSite(SiteType.PORTAL, "test_layout_page"), "page", new PageState.Builder().build());
createElements(page, FOO_PORTLET, BAR_PORTLET);
String layoutId = page.layoutId;
NodeContext<Element, ElementState> pageContext = layoutService.loadLayout(Element.MODEL, layoutId, null);
assertEquals(2, pageContext.getNodeSize());
Element foo = pageContext.getNode(0);
Element bar = pageContext.getNode(1);
testInfo(foo, bar);
@nttuyen
nttuyen / Bội chi ngân sách Nhà nước 2014
Last active August 29, 2015 14:12
Biêu đồ tổng hợp 2014
{
config: {
title: "Bội chi ngân sách Nhà nước 2014",
width: 1000, // Độ rộng biểu đồ
height: 300, // Chiều cao biểu đồ
groupWidth: 0, // Dộ rộng cột của biểu đồ
isStacked: false
},
columns: ['Bội chi ngân sách'],
data: [
{
gists: [
'https://api.github.com/gists/b346dd60a98a3c686c80',
'https://api.github.com/gists/90c293c95139061d06f2'
],
charts:[
]
}