Skip to content

Instantly share code, notes, and snippets.

View yeungon's full-sized avatar
💭
In JavaScript we trust

Vuong Nguyen yeungon

💭
In JavaScript we trust
View GitHub Profile
[aAàÀảẢãÃáÁạẠăĂằẰẳẲẵẴắẮặẶâÂầẦẩẨẫẪấẤậẬbBcCdDđĐeEèÈẻẺẽẼéÉẹẸêÊềỀểỂễỄếẾệỆfFgGhHiIìÌỉỈĩĨíÍịỊjJkKlLmMnNoOòÒỏỎõÕóÓọỌôÔồỒổỔỗỖốỐộỘơƠờỜởỞỡỠớỚợỢpPqQrRsStTuUùÙủỦũŨúÚụỤưƯừỪửỬữỮứỨựỰvVwWxXyYỳỲỷỶỹỸýÝỵỴzZ]+
let vietnameseCharacters = `AÀẢÃÁẠĂẰẲẴẮẶÂẦẨẪẤẬBCDĐEÈẺẼÉẸÊỀỂỄẾỆGHIÌỈĨÍỊKLMNOÒỎÕÓỌÔỒỔỖỐỘƠỜỞỠỚỢPQRSTUÙỦŨÚỤƯỪỬỮỨỰVXYỲỶỸÝỴ`
@yeungon
yeungon / all-vietnamese-syllables.txt
Created May 4, 2022 14:59 — forked from hieuthi/all-vietnamese-syllables.txt
All possibly existent Vietnamese syllables, created by combine all onsets with all rimes. More information can be found at: http://hieuthi.com/blog/2017/03/21/all-vietnamese-syllables.html
a
ai
am
an
ang
anh
ao
au
ay
ba
@yeungon
yeungon / slug.js
Created April 4, 2022 10:59 — forked from bluzky/slug.js
Remove vietnamese accent javascript / Bỏ dấu tiếng Việt
function stringToSlug(str) {
// remove accents
var from = "àáãảạăằắẳẵặâầấẩẫậèéẻẽẹêềếểễệđùúủũụưừứửữựòóỏõọôồốổỗộơờớởỡợìíỉĩịäëïîöüûñçýỳỹỵỷ",
to = "aaaaaaaaaaaaaaaaaeeeeeeeeeeeduuuuuuuuuuuoooooooooooooooooiiiiiaeiiouuncyyyyy";
for (var i=0, l=from.length ; i < l ; i++) {
str = str.replace(RegExp(from[i], "gi"), to[i]);
}
str = str.toLowerCase()
.trim()
@yeungon
yeungon / axios.js
Created March 30, 2022 04:06
download binary file using Axios
async function getAudioFileFromEconomist(fileUrl) {
const writer = fs.createWriteStream("economist_audio.mp3");
return axios({
method: "get",
url: fileUrl,
responseType: "stream",
}).then((response) => {
return new Promise((resolve, reject) => {
response.data.pipe(writer);
let error = null;
@Module({
imports: [
StoresModule,
UserModule,
TypeOrmModule.forRoot({
type: 'mysql',
// "db" is the name of the service declared in docker-compose.yml, NOT localhost https://stackoverflow.com/questions/63492744/dockerize-nestjs-and-typeorm
host: 'db',
port: 3306,
@yeungon
yeungon / Dockerfile
Created January 7, 2022 14:28 — forked from nzvtrk/Dockerfile
Nest.js multi-stage build dockerfile + docker-compose with postgres & migrations
FROM node:12.14.1-alpine AS build
# If you have troubles with node-gyp use should install these dependencies
RUN apk add g++ make python
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . ./
# build js & remove devDependencies from node_modules
@yeungon
yeungon / Encryption.js
Created December 10, 2021 02:14 — forked from ve3/Encryption.js
Encrypt and decrypt between programming languages (PHP & JavaScript).
/**
* Encryption class for encrypt/decrypt that works between programming languages.
*
* @author Vee Winch.
* @link https://stackoverflow.com/questions/41222162/encrypt-in-php-openssl-and-decrypt-in-javascript-cryptojs Reference.
* @link https://github.com/brix/crypto-js/releases crypto-js.js can be download from here.
*/
class Encryption {
@yeungon
yeungon / webkit-pseudo-elements.md
Created November 28, 2021 12:03 — forked from leostratus/webkit-pseudo-elements.md
Webkit Pseudo-Element Selectors (Shadow DOM Elements)

An ongoing project to catalogue all of these sneaky, hidden, bleeding edge selectors as I prepare my JSConf EU 2012 talk.

Everything is broken up by tag, but within each the selectors aren't particularly ordered.

I have not tested/verified all of these. Have I missed some or got it wrong? Let me know. - A

A friendly reminder that you may need to set this property on your target/selected element to get the styling results you want:

-webkit-appearance:none;

@yeungon
yeungon / playAudioAsBlobViaAjax.js
Created November 26, 2021 08:10 — forked from praveenpuglia/playAudioAsBlobViaAjax.js
Download Audio from AJAX and Play as Blob
var a = fetch("http://path/to/audio.wav")
.then(res => {
var reader = res.body.getReader();
return reader.read().then(result => {
return result;
});
})
.then(data => {
console.log(data);
@yeungon
yeungon / gist:f83b9898794391478259ae3b436a5baa
Created October 5, 2021 05:05 — forked from nemesisqp/gist:8d47707f3de009b5df07d44052407c0a
3000 từ hán việt phổ biến (1 từ có thể có nhiều nghĩa khác nhau)
THIÊN: Trời
ĐỊA: Đất
CỬ: Cất
TỒN: Còn
TỬ: Con
TÔN: Cháu
LỤC: Sáu
TAM: Ba
GIA: Nhà
QUỐC: Nước