Skip to content

Instantly share code, notes, and snippets.

View ngxson's full-sized avatar

Xuan-Son Nguyen ngxson

View GitHub Profile
@ngxson
ngxson / timezone.js
Last active April 24, 2024 18:52
ESP32Time time offset table
/**
* This file calculates a lookup table for all the day that daylight saving take effect.
* The output file is a hpp file, which can use used in Arduino project.
* If you don't have nodejs on your machine, you can use an online compiler, for example: https://www.tutorialspoint.com/execute_nodejs_online.php
*/
// number of years in the future to generate
const NB_OF_YEARS = 20;
// set the current timezone
@ngxson
ngxson / ATC_MiThermometer.ino
Created December 8, 2023 18:09
ATC_MiThermometer.ino
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
int scanTime = 5; // In seconds
BLEScan * pBLEScan;
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) {
@ngxson
ngxson / wgui.path
Created August 17, 2023 19:48
Wireguard GUI
[Unit]
Description=Watch /etc/wireguard/wg0.conf for changes
[Path]
PathModified=/etc/wireguard/wg0.conf
[Install]
WantedBy=multi-user.target
@ngxson
ngxson / default.conf
Last active February 15, 2023 19:03
Portainer docker + JS injection
js_path "/etc/nginx/conf.d/";
js_import main from default.js;
server {
listen 9443 default_server ssl http2;
listen [::]:9443 default_server ssl http2;
ssl_certificate /certs/cert.pem;
ssl_certificate_key /certs/key.pem;
set $target "http://172.17.0.1:9000";
@ngxson
ngxson / documentation.md
Last active March 4, 2023 08:46
Tài liệu hướng dẫn sử dụng Nui Chatbot API

Hướng dẫn sử dụng API của NuiChatbot:

  • Bạn cần lấy token (đầu NUIEAA...) từ web của NuiChatbot.
  • Đối với những chỗ trong code của bạn tạo request tới https://graph.facebook.com/..., chuyển thành http://api.chatbot.ngxson.com/graph/...
  • Bỏ những chỗ có version, ví dụ /v2.6/messages thì phải sửa thành /messages
  • Bỏ https, thay bằng http [2]
  • Nui Chatbot API chỉ hỗ trợ các endpoint và method như bảng sau:

|graph.facebook.com|api.chatbot.ngxson.com|method|Ghi chú|

@ngxson
ngxson / command.bat
Last active February 29, 2020 11:05
protectvideodownload dot com
ffmpeg -protocol_whitelist file,https,http,crypto,data,tls -i ./video.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4
@ngxson
ngxson / music-transpose.ipynb
Last active May 11, 2020 11:54
Music Transpose.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ngxson
ngxson / source.c
Created November 15, 2019 13:10
TD2
#include <stdio.h>
int main() {
#ifdef _POSIX_SOURCE
printf("_POSIX_SOURCE=%d\n", _POSIX_SOURCE);
#endif
#ifdef _SVID_SOURCE
printf("_SVID_SOURCE=%d\n", _SVID_SOURCE);
#endif
@ngxson
ngxson / index.js
Created August 3, 2019 21:07
tonghopevent-autorep2
const fs = require('fs')
let content = fs.readFileSync('./input.txt').toString()
content = content.replace(/\$\$\$\$\$\$\$\$\$\$/g, '▓')
content = content.split('▓')
function toWordArray(c) {
let words = c.replace(/\n/g, ' ').split(' ')
words = words.map(w => {
return w.toLowerCase()