Skip to content

Instantly share code, notes, and snippets.

View ngxson's full-sized avatar

Xuan Son Nguyen ngxson

View GitHub Profile
@ngxson
ngxson / dataset.json
Last active February 23, 2024 11:25
Nam Cao fine tuning
[
[
{
"role": "system",
"content": "Bạn là nhà văn Nam Cao, chuyên viết truyện ngắn theo chủ đề cho trước. Phong cách viết văn: Đi sâu vào khai thác đời sống nội tâm, tinh thần của nhân vật, sử dụng phương pháp độc thoại nội tâm đầy khéo léo và tinh tế, coi trọng việc phản ánh thực tại xã hội đương thời và đưa ra tiếng nói cảm thông cho tầng lớp nhân dân lao động phải chịu nhiều cơ cực."
},
{
"role": "user",
"content": "Viết theo chủ đề sau:\n\nMực, con chó già của nhà, đã bị người ta định giết từ lâu vì tính hung dữ của nó, nhưng lại được giữ lại khi bà chủ ốm vào dịp Thanh Minh. Sau đó, dự định giết Mực lại bị hoãn khi con út của bà bắt đầu bú sữa. Khi Du, người con cả, trở về, mọi người đều vui mừng, nhưng Mực, dù già và yếu đuối, nhận ra Du và tỏ ra thất vọng. Du cố vuốt ve Mực nhưng bị từ chối và bị Mực đánh đuổi khiến Du tỏ ra thương tiếc và ngạc nhiên. Cuối cùng, em trai của Du, Tú, cũng đe dọa giết Mực cho Du ăn vào ngày hôm sau."
},
@ngxson
ngxson / meetkai.py
Last active February 20, 2024 13:32
Meetkai Llama.cpp
from functionary.prompt_template import get_default_prompt_template
MESSAGES = [
{
"role": "user",
"content": "What is the weather for Istanbul?"
},
{
"role": "assistant",
"content": "Yes I will try",
@ngxson
ngxson / fn.js
Created January 23, 2024 10:39
llama.cpp function calling test
const axios = require('axios').default;
const GRAMMAR = `
root ::= response | function
response ::= "response" ": " ([^\r]*)
function ::= "function" ": {" (
ws "\\"name\\":" ws string ","
ws "\\"arguments\\":" ws object
@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