Skip to content

Instantly share code, notes, and snippets.

View tranchausky's full-sized avatar
🏹
done

tranchausky

🏹
done
View GitHub Profile
@tranchausky
tranchausky / file.php
Created April 19, 2024 03:28
wp php return file png from content base64
<?php
/*
* Template Name: Template-return-png
* Description: A Page Template with a darker design.
*/
$database64 = '';
if(isset($_GET['id'])){
@tranchausky
tranchausky / functions.php
Created April 19, 2024 02:08
wp need login not sub page free
<?php
//every page need login
//not page of /free
//http://myweb.com/free
//http://myweb.com/free/page1
//http://myweb.com/free/page2....
function _nok_force_user_login() {
global $wp;
@tranchausky
tranchausky / TextUtil.php
Created April 17, 2024 10:21 — forked from khoatran/TextUtil.php
Convert Vietnamese string to slug
<?php
class TextUtil {
public static function sanitize($title) {
$replacement = '-';
$map = array();
$quotedReplacement = preg_quote($replacement, '/');
$default = array(
'/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ|À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ|å/' => 'a',
'/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ|È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ|ë/' => 'e',
'/ì|í|ị|ỉ|ĩ|Ì|Í|Ị|Ỉ|Ĩ|î/' => 'i',
@tranchausky
tranchausky / translate_tts
Created April 17, 2024 09:53
google translate_tts
vietnam
translate.google.com/translate_tts?ie=UTF-8&q=%C4%83n%20n%C3%AAn%20l%C3%A0m%20ra&tl=vi&total=1&idx=0&textlen=15&tk=350535.255567&client=webapp&prev=input
eng
translate.google.com/translate_tts?ie=UTF-8&q=This%20is%20a%20test.&tl=en&total=1&idx=0&textlen=15&tk=350535.255567&client=webapp&prev=input
@tranchausky
tranchausky / hardware-esp8266.ino
Last active April 2, 2024 10:52
esp32/esp8266 get hardware infor (RAM/ROM)
#include <WiFi.h>
//#include <ESP8266WiFi.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
printHardwareInfo();
printBoardName();
printMacIp();
@tranchausky
tranchausky / auto-5minus.js
Created April 1, 2024 01:40
jqueyr auto call function after 5 minus if no event mouse or keyboard in page
let idleTime = 0;
// Increment idle time every second
setInterval(timerIncrement, 1000);
// Reset idle time on mouse or keyboard event
$(document).on('mousemove keydown', function() {
idleTime = 0;
});
@tranchausky
tranchausky / index.php
Last active March 27, 2024 08:33
php return last version
<?php
$folderVersion = 'versions';
$version = retunVersion($folderVersion);
$file_BIN = 'file.BIN';
$link = 'http://localhost:801/test/upgrade/versions/';
echo viewFileBin($link,$version, $file_BIN);
function viewFileBin($link,$version, $file_BIN){
@tranchausky
tranchausky / doc.txt
Created March 26, 2024 07:31
wp create template page use plugin get random by category
active plugin
create new page with template Chau-Random A Title Post
access link of page
can find by categry slug https://mydomain.com/random/?catname=thanh-cong
@tranchausky
tranchausky / php-get-calendar-public.php
Created March 21, 2024 09:03
get 8 day data from google calader (Use this URL to access this calendar from a web browser.)
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$input = 'https://calendar.google.com/calendar/embed?src=a56ac6da1d0184b389b3f590ba25b686b1bc6580f5666b0c6ae63259b31cbb1b%40group.calendar.google.com&ctz=Asia%2FHo_Chi_Minh';
$resl = builLink($input);
@tranchausky
tranchausky / php-resizemage.php
Last active February 21, 2024 03:54
php resize image (laravel -plupload)
<?php
namespace App\Services;
use Illuminate\Filesystem\Filesystem;
class FileUploadChurkService extends BaseService
{
public function __construct()
{