Skip to content

Instantly share code, notes, and snippets.

View 18520339's full-sized avatar
😵
Night Owl

Quan Dang 18520339

😵
Night Owl
View GitHub Profile
@18520339
18520339 / vietnamese_preprocessor.py
Last active June 29, 2024 23:27
Preprocess Vietnamese text data
# https://github.com/behitek/text-classification-tutorial/blob/master/text_classification_tutorial.ipynb
import os
import emoji
import urllib
import requests
import regex as re
from io import StringIO
from vncorenlp import VnCoreNLP
from transformers import pipeline
@18520339
18520339 / data.aql
Created March 27, 2024 14:49
Distributed Database - ArangoDB Cluster Setup
// INSERT HOADON
FOR hoadon in [
{MAHD: "HD01", KHACHHANG: "Nguyen Duc Tri", SDT: "0937859594", DIACHI: "Ap 3,Tan Thanh, Thu Thua, Long An", MANV: "NV04"},
{MAHD: "HD02", KHACHHANG: "Nguyen Hoang Nhan", SDT: "028347852", DIACHI: "Tan Mai, Bien Hoa, Dong Nai", MANV: "NV03"},
{MAHD: "HD03", KHACHHANG: "Dang Hoang Quan", SDT: "036845271", DIACHI: "Phuong 15, Tan Binh, TP.HCM", MANV: "NV04"},
{MAHD: "HD04", KHACHHANG: "Nguyen Duc Tri", SDT: "0937859594", DIACHI: "Ap 3,Tan Thanh, Thu Thua, Long An", MANV: "NV03"}
] INSERT hoadon INTO HOADON
// INSERT NHANVIEN
FOR nhanvien IN [
@18520339
18520339 / vcard2csv.py
Created March 22, 2024 14:44
Export iCloud vCard contacts to csv
import csv
import vobject
def vcard_to_csv(vcard_filename, csv_filename):
with open(vcard_filename, 'r', encoding='utf-8') as vcard_file:
vcards = vobject.readComponents(vcard_file.read())
with open(csv_filename, mode='w', newline='', encoding='utf-8') as csv_file:
fieldnames = ['Name', 'Phone(s)', 'Email(s)', 'Address(es)']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
@18520339
18520339 / poe.js
Created October 6, 2023 10:21
customize poe
javascript:(function(){
document.querySelector('.MainColumn_column__UEunw').style.width = '100%';
document.querySelector('.ChatPageMain_container__2O2h8').style.maxWidth = '100%';
document.querySelectorAll('.Message_botMessageBubble__aYctV, .Message_humanMessageBubble__DtRxA').forEach(mess => mess.style.maxWidth='100%');
var addCSS = css => document.head.appendChild(document.createElement("style")).innerHTML = css;
addCSS('::-webkit-scrollbar { width: unset!important }');
addCSS('::-webkit-scrollbar-thumb { background-color: lightgray }');
})();
@18520339
18520339 / rename.sh
Last active December 29, 2023 09:18
My study notes 2
# https://stackoverflow.com/questions/7992689/how-to-loop-over-files-in-natural-order-in-bash
# https://stackoverflow.com/questions/3211595/renaming-files-in-a-folder-to-sequential-numbers
readarray -d '' entries < <(printf '%s\0' *.png | sort -zV)
num=10846
for entry in "${entries[@]}"; do
new=$(printf "%07d.png" "$num") #07 pad to length of 7
mv -i -- "$entry" "$new"
echo "${entry} -> ${new}"
let num=num+1
@18520339
18520339 / index.html
Last active September 13, 2022 10:58
Interactive 3D Character with Three.js
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Interactive 3D Character with Three.js | Codrops</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script>
document.documentElement.className = 'js';
let supportsCssVars = () => {
@18520339
18520339 / InstallPython.ps1
Last active March 20, 2022 10:33
Install Python amd64 via Windows Powershell
# Ask for administrator privilege
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
exit;
}
# Check if Python exists before installation
if(&{python -V} 2>&1 -is [System.Management.Automation.ErrorRecord]) {
$TEMP_DIR = [System.IO.Path]::GetTempPath()
$PYTHON_VERSION = "3.8.10" # Specify Python version from https://www.python.org/downloads/windows
@18520339
18520339 / PredictVietnameseTone.bas
Last active January 1, 2022 15:29
Predict Vietnamese tone in Excel
'(VN) Hàm thêm dấu Tiếng Việt & sửa lỗi chính tả cho Excel
'(EN) Predict Vietnamese tone & spell checking for Excel
#If VBA7 Then 'For 64 Bit Systems
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
#Else 'For 32 Bit Systems
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If
Function FormatResponse(response As Object, sentence As String) As String
Dim wordSuggestion As Dictionary
@18520339
18520339 / EnableMacros.cs
Last active September 29, 2021 05:44
Enable VBA Macros for Excel automatically
using Microsoft.Win32;
using System.Diagnostics;
using System.IO;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
// https://www.kunal-chowdhury.com/2016/06/how-to-retrieve-office-version.html
// Enable for default Office version
string regOutlook32Bit = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE";
@18520339
18520339 / youtube_playlist_time.js
Last active February 25, 2022 17:45
Calculate the total time of a Youtube playlist by seconds
[...document.querySelectorAll('ytd-thumbnail-overlay-time-status-renderer>span')].map(el => {
let timeSplit = el.innerText.split(':');
let lastIndex = timeSplit.length - 1;
let second = timeSplit[lastIndex] * 1;
for (let i = 0; i < lastIndex; i++)
second += timeSplit[i] * 60 ** (lastIndex - i);
return second;
}).reduce((total, second) => total + second);
/*