Skip to content

Instantly share code, notes, and snippets.

@lelinh
lelinh / workflow.yml
Created September 7, 2024 05:44 — forked from doctor-g/workflow.yml
Workflow to publish a Flutter Web app to GitHub Pages
name: Deploy to GitHub Pages
on:
workflow_dispatch:
push:
branches:
- master
jobs:
deploy:
//
// JSONMappable.swift
//
// Created by Linh Le Manh on 14/01/2022.
//
import SwiftyJSON
protocol JSONMappable {
init?(json: JSON)
@lelinh
lelinh / apns.sh
Created May 13, 2022 07:46 — forked from greencoder/apns.sh
Curl the APNS http/2 API
# Note: You MUST have curl 7.47+ with http/2 support compiled in
curl -v \
-d '{"aps":{"alert":"<message>","badge":42}}' \
-H "apns-topic: <bundle id>" \
-H "apns-priority: 10" \
--http2 \
--cert <certificate file> \
https://api.development.push.apple.com/3/device/<device token>
@lelinh
lelinh / letsencrypt_2020.md
Created July 22, 2020 09:19 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@lelinh
lelinh / nginxproxy.md
Created July 22, 2020 09:17 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
# https://www.howtoforge.com/tutorial/how-to-setup-zsh-and-oh-my-zsh-on-linux/
apt install zsh
chsh -s /usr/bin/zsh root
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

Install Zsh and Oh-my-zsh on CentOS 7

Based on this article

ALL INSTALLATIONS ASSUME YES WHEN PROMPTED, that's what -y does

This script can be copy paste to ssh as is. No hands installation. :-)

yum install zsh -y
@lelinh
lelinh / install_zsh_in_ubuntu.md
Last active October 15, 2019 04:49
install zsh in ubuntu

Update apt

sudo apt-get update
sudo apt upgrade

Install prerequisite packages (ZSH, powerline & powerline fonts)

sudo apt install zsh
sudo apt-get install powerline fonts-powerline
@lelinh
lelinh / ioslocaleidentifiers.csv
Last active December 25, 2017 03:14 — forked from jacobbubu/ioslocaleidentifiers.csv
iOS Locale Identifiers
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@lelinh
lelinh / String_Extension.swift
Last active July 16, 2017 11:22
remove diacritic in Vietnamese; get substring; replace a substring with another; string to NSAttributedString
extension String{
func removeDiacritic() -> String {
var temp2 = self
for character in "ạảãàáâậầấẩẫăắằặẳẵ".characters{
temp2 = temp2.replace(String(character), "a")
}
for character in "óòọõỏôộổỗồốơờớợởỡ".characters{
temp2 = temp2.replace(String(character), "o")
}