Skip to content

Instantly share code, notes, and snippets.

View tranchausky's full-sized avatar
🏹
done

tranchausky

🏹
done
View GitHub Profile
@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');
@tranchausky
tranchausky / get last record no empty of file big.php
Created August 21, 2024 15:41
file lớn, đọc ngược từ cuối file, đọc theo khối dữ liệu
<?php
function getLastNonEmptyLine($file) {
$fp = fopen($file, 'r');
$pos = -1;
$line = '';
$block = '';
if ($fp === false) {
#include <WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <TimeLib.h>
// Replace with your network credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// NTP Server settings
<?php
// Define the timezone identifier for California
$timezoneIdentifier = 'America/Los_Angeles';
// Create a DateTimeZone object with the specified timezone
$timezone = new DateTimeZone($timezoneIdentifier);
// Get the timezone offset in seconds
$offset = $timezone->getOffset(new DateTime('now', $timezone));
@tranchausky
tranchausky / log.php
Created July 25, 2024 04:43
php function log file \logs\idkey\2024-07.txt
<?php
$folderLog= 'logs/';
$key = 'idkey';
$str = 'this is message to file';
logFile($folderLog, $key, $str);
function logFile($folderLog, $keyFolder, $stringToAppend, $formatFile =''){
if(!file_exists($folderLog)){
@tranchausky
tranchausky / run.bat
Created July 24, 2024 22:24
win auto open more software one click
@echo off
start "" "C:\Users\tranc\AppData\Local\GitHubDesktop\GitHubDesktop.exe"
start "" "C:\Program Files\Notepad++\notepad++.exe"
start "" "C:\Users\tranc\AppData\Local\Programs\Microsoft VS Code\Code.exe"
start "" "C:\Program Files\Google\Chrome\Application\chrome.exe" --profile-directory="Default""
@tranchausky
tranchausky / input-suggest.html
Created July 24, 2024 04:16
javascript input suggest when keypress
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Input Suggestions with Keyboard Navigation</title>
<style>
/* Basic styling for suggestions */
.suggestions-container {
border: 1px solid #ccc;
@tranchausky
tranchausky / different.js
Last active June 14, 2024 06:27
jquery send ajax json
var settings = {
"url": "https://website.local:8443/api/event-checkin",
"method": "POST",
"timeout": 0,
"headers": {
"username": "usename",
"password": "password",
"Content-Type": "application/json"
},
"data": JSON.stringify({