Skip to content

Instantly share code, notes, and snippets.

View trbhoang's full-sized avatar

Hoang Tran trbhoang

  • Ho Chi Minh City
View GitHub Profile

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

#include <iostream>
#include <cstdlib>
void sort(char* array[], int size) {
char* chars = *array;
int counts[26] = {0};
for (auto i = 0; i < size; i++) {
counts[int(chars[i] - 'A') % 26]++;
}
@trbhoang
trbhoang / gist:b74b4129162bb71e4dc2aef7221e17bb
Created June 17, 2021 04:32 — forked from madis/gist:4650014
Testing CORS OPTIONS request with curl
curl \
--verbose \
--request OPTIONS \
http://localhost:3001/api/configuration/visitor \
--header 'Origin: http://localhost:9292' \
--header 'Access-Control-Request-Headers: Origin, Accept, Content-Type' \
--header 'Access-Control-Request-Method: GET'
# http://nils-blum-oeste.net/cors-api-with-oauth2-authentication-using-rails-and-angularjs/#.UQJeLkp4ZyE
@trbhoang
trbhoang / ubuntu_unattended_upgrades_gmail.markdown
Created February 7, 2020 08:36 — forked from roydq/ubuntu_unattended_upgrades_gmail.markdown
Unattended upgrades on Ubuntu 14.04 with email notifications

Getting Started

Do yourself a favor and login as root to save yourself some time and headaches:

$ sudo su -

Install unattended-upgrades:

@trbhoang
trbhoang / .bash_profile
Created November 21, 2014 07:13
name terminal's tab title as hostname on Mac OS
# refs:
# https://coderwall.com/p/hox_hq/keep-terminal-app-tab-name-follow-working-host
# http://wiki.bash-hackers.org/scripting/posparams
#
# customize Terminal tab title
#
function tabname () {
# Change Terminal.app tab name (by josjbuhler)
echo -en "\033];$1\007"
@trbhoang
trbhoang / gist:dc15187264ad806d4f2a
Created November 19, 2014 02:53
Resync git repo with new gitignore file
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"