Skip to content

Instantly share code, notes, and snippets.

View tranchausky's full-sized avatar
🏹
done

chautran tranchausky

🏹
done
  • Ha Noi, Nghe An
View GitHub Profile
@tranchausky
tranchausky / when close.js
Created April 8, 2025 09:17
javascript call when close tab current
window.addEventListener('beforeunload', function (e) {
console.log('Tab is about to be closed');
// Optionally show a confirmation dialog (not supported in all browsers)
e.preventDefault();
e.returnValue = '';
});
@tranchausky
tranchausky / for_login.php
Last active April 5, 2025 09:45
login logout php basic
<?php
session_start();
$php_main = 'main.php';
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['logout'])) {
session_start();
session_destroy();
header("Location: $php_main");
exit;

Test cross

tranc@DESKTOP-SBDJJJT MINGW64 ~
$ curl -i -X OPTIONS http://192.168.1.33:21680/completed/704_59_0/2025/03/1742835485.ts
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0HTTP/1.1 200 OK
Date: Tue, 25 Mar 2025 11:41:19 GMT
Server: Apache/2.4.62 (CentOS Stream)
@tranchausky
tranchausky / cookie.css
Created March 18, 2025 04:02
cookie basic
@tranchausky
tranchausky / cookieconsent-config.js
Created March 18, 2025 03:59
cách load js module
import 'https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.umd.js';
// Enable dark mode
document.documentElement.classList.add('cc--darkmode');
CookieConsent.run({
guiOptions: {
consentModal: {
layout: "box",
position: "bottom left",
@tranchausky
tranchausky / save.php
Created March 17, 2025 04:45
javascript get post ajax example template
<?php
$data=[
'staus'=>true,
'msg'=>'welcome',
];
echo json_encode($data);
@tranchausky
tranchausky / diagram.json
Last active March 12, 2025 10:04
esp32 test connect server internet
{
"version": 1,
"author": "Tran Chau",
"editor": "wokwi",
"parts": [ { "type": "board-esp32-devkit-c-v4", "id": "esp", "top": 0, "left": 0, "attrs": {} } ],
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ],
"dependencies": {}
}
@tranchausky
tranchausky / main.cpp
Created January 20, 2025 15:28
esp32 s2 mini connect to SSD1306 (33-35)
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Define the OLED display width and height
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
@tranchausky
tranchausky / diagram.json
Created October 30, 2024 04:08
switch relay 3 with interrupt -ok
{
"version": 1,
"author": "cccc",
"editor": "wokwi",
"parts": [
{ "type": "board-esp32-devkit-c-v4", "id": "esp", "top": -86.4, "left": -23.96, "attrs": {} },
{
"type": "wokwi-relay-module",
"id": "relay1",
"top": -77.4,
@tranchausky
tranchausky / a php mqtt push hivemq 8883.php
Created October 28, 2024 09:41
php mqtt push hivemq 8883
<?php
//https://github.com/php-mqtt/client/tree/master
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require('vendor/autoload.php');