Skip to content

Instantly share code, notes, and snippets.

@tieubao
tieubao / one_liners.md
Created April 8, 2020 19:57 — forked from brannondorsey/one_liners.md
One Liners

Count the number of unique characters in a file

# https://unix.stackexchange.com/questions/5010/how-can-i-count-the-number-of-different-characters-in-a-file
# works for linux. There is a variation for MacOS in the link ^
sed 's/\(.\)/\1\n/g' text.txt | sort | uniq -c # sort -nr # uncomment this to sort the list by frequency

Replace a string in all instances of files in a directory

@tieubao
tieubao / traffic.sh
Created April 8, 2020 19:43 — forked from radu-gheorghe/traffic.sh
bash script for checking out traffic via /proc/net/dev
#!/bin/bash
#shows traffic on the specified device
function human_readable {
VALUE=$1
BIGGIFIERS=( B K M G )
CURRENT_BIGGIFIER=0
while [ $VALUE -gt 10000 ] ;do
VALUE=$(($VALUE/1000))
@tieubao
tieubao / tcp_flags.txt
Created April 8, 2020 19:26 — forked from tuxfight3r/tcp_flags.txt
tcpdump - reading tcp flags
##TCP FLAGS##
Unskilled Attackers Pester Real Security Folks
==============================================
TCPDUMP FLAGS
Unskilled = URG = (Not Displayed in Flag Field, Displayed elsewhere)
Attackers = ACK = (Not Displayed in Flag Field, Displayed elsewhere)
Pester = PSH = [P] (Push Data)
Real = RST = [R] (Reset Connection)
Security = SYN = [S] (Start Connection)
@tieubao
tieubao / notion2blog.js
Created April 7, 2020 21:06 — forked from mayneyao/notion2blog.js
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@tieubao
tieubao / docker-cleanup-resources.md
Created December 21, 2019 08:02 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@tieubao
tieubao / README.MD
Created June 10, 2019 16:36 — forked from duythinht/README.MD
That was a thing, which I want.
  • Must have Dockerfile inside project, that able to run docker built -t test:1.0.0 ./
  • Image must be expose port as 80
  • Image after build could run directly without any config file, config only accept to inject by environment variables
docker run -e "MYSQL_HOST=127.0.0.1" -e "MYSQL_USERNAME=root" test:1.0.0
  • Must have Jenkins file follow this pattern
pipeline {
    agent any
@tieubao
tieubao / macos_on_ubuntu.md
Created April 7, 2019 17:25 — forked from stefanocoding/macos_on_ubuntu.md
Install macOS in a VirtualBox machine on Ubuntu

Important: I'm writing this when the last version of macOS (and the one I have installed) is Mojave. There is already a script which installs Mojave in a virtual machine here https://github.com/img2tab/okiomov. But if you are curios how to do everything manually to install High Sierra, then this guide may be useful.

After reading a few articles I ended up with these steps:

  1. On macOS, download the High Sierra installer (even if you have Mojave installed): https://itunes.apple.com/us/app/macos-high-sierra/id1246284741?ls=1&mt=12
  2. If the High Sierra Installer starts, quit it.
  3. Open "Disk Utility".
  4. Click on "File" > "New Image" > "Blank image...". Or just press cmd+N.
@tieubao
tieubao / no-hackerrank.md
Created February 26, 2018 14:56 — forked from fasiha/no-hackerrank.md
A prospective employer invited me to do a HackerRank test. Here's my proposed alternative.
To: [email protected]
From: Ahmed Fasih
Subject: Re: Programming Test Invitation

Hi there! Thanks for offering to let me take a HackerRank test for ABC, I appreciate the vote of confidence.

I'd never heard of HackerRank, but after you wrote two other employers sent me their own HackerRank tests. Having worked on those tests first (I considered them practice, for the real thing with ABC :), I'd like to check if you have flexibility in finding an alternative way to evaluate my basic coding chops.

This is because, as functional programmer and author Paul Chiusano says, "Programming is all about managing complexity" [1], but HackerRank is quite bad at measuring my ability to manage complexity. It asks for small algorithmic coding puzzles to be done in unnatural conditions including (1) time limits, (2) forbidding research on Wikipedia or StackOverflow, (3) forbidding collaboration, and (4) forbidding the use of libraries (Python and JavaScript e.g. are so different when confined to thei

@tieubao
tieubao / latency.txt
Created January 31, 2017 19:49 — 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