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 / binary_search.bas
Last active February 25, 2022 17:40
Tìm kiếm nhị phân bằng VBA
Function BinarySearch(strArray() As String, strSearch) As Long
Dim Left As Long, Middle As Long, Right As Long
Left = 1
Right = UBound(strArray, 1)
Do While Left <= Right
Middle = Left + (Right - Left) / 2
If strSearch = strArray(Middle, 1) Then
BinarySearch = Middle
@18520339
18520339 / find_longest_substring.cpp
Last active October 15, 2021 11:42
Tìm chuỗi con chung dài nhất
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int lookup[100][100];
// Đổ dữ liệu cho mảng lookup bằng cách tìm độ dài của dãy con chung
int LCSLength(string s1, string s2, int l1, int l2) {
// Hàng đầu tiên và cột đầu tiên của mảng lookup bằng 0 vì mảng lookup đã được khai báo toàn cục
@18520339
18520339 / files_folders.cpp
Last active August 24, 2021 15:43
Design Patterns - Composite
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Item {
protected:
string ten;
public:
@18520339
18520339 / index.html
Last active April 9, 2021 20:09
Access Camera & Micro - https://teststream.web.app/
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="container">
<div class="select">
<label for="audioSource">Audio source: </label>
<select id="audioSource"></select>
@18520339
18520339 / eicar.com
Created February 2, 2021 15:34
Test Antivirus
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
@18520339
18520339 / simple-encrypt-virus.cpp
Last active August 24, 2021 15:38
Simple encrypt virus in C++
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream EncodeFile("encode.jpg", ifstream::binary);
ofstream DecodeFile("decode.jpg", ofstream::binary);
if (EncodeFile) {
EncodeFile.seekg (0, EncodeFile.end);
@18520339
18520339 / optimize_basic_functions.cpp
Last active February 18, 2024 02:41
My study notes
#include <iostream>
#include <math.h>
using namespace std;
bool is_prime(int n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i += 6)
if (n % i == 0 || n % (i + 2) == 0) return false;
@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);
/*
@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 / 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