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
const fs = require("fs");
const path = require("path");
const folderPath = __dirname + "/MBall_sections_applx_RAs_MARKUP";
const outputFolderPath = __dirname + "/conclusion";
fs.readdir(folderPath, (err, files) => {
if (err) {
console.error("Error reading folder:", err);
return;
@yeungon
yeungon / docker_wordpress.md
Created August 2, 2023 16:43 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
/* nếu screen <= 1440px */
@media only screen and (max-width: 1440px) {
}
/* nếu screen <= 1366px */
@media only screen and (max-width: 1366px) {
@yeungon
yeungon / inject.js
Created December 4, 2022 07:05
inject css and js to chrome extension
/**
* injectScript - Inject internal script to available access to the `window`
*
* @param {type} file_path Local path of the internal script.
* @param {type} tag The tag as string, where the script will be append (default: 'body').
* @see {@link http://stackoverflow.com/questions/20499994/access-window-variable-from-content-script}
* @reference https://gist.github.com/devjin0617/3e8d72d94c1b9e69690717a219644c7a?permalink_comment_id=3766826#gistcomment-3766826
*/
function injectScript(file_path, tag) {
var node = document.getElementsByTagName(tag)[0];
@yeungon
yeungon / readasync.js
Last active November 16, 2022 03:32
Read huge JSON with Node
const StreamArray = require('stream-json/streamers/StreamArray');
const fs = require('fs');
let combine = "Working_Vietnamese_English_Combined.json";
let vnedict = `vnedict__vietnamese-english.json`
const jsonStream = StreamArray.withParser();
fs.createReadStream(vnedict).pipe(jsonStream.input);
[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,