Skip to content

Instantly share code, notes, and snippets.

@Traineratwot
Traineratwot / Console.php
Last active April 23, 2022 14:03
Простой класс для работы с консолью. особенностью является функция prompt которая позволяет делать диалог
<?php
class Console
{
/**
* @var string[]
*/
public static $FOREGROUND_COLORS
= [
'black' => '0;30',
'dark_gray' => '1;30',
<?php
namespace traineratwot;
use FilesystemIterator;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RuntimeException;
use SplFileInfo;
class ThreeWayCheckbox {
private elem: JQuery<HTMLElement>;
state = 0;
private callbacks: Function[] = [];
constructor(elem: JQuery<HTMLElement>) {
this.elem = elem
try {
this.elem.on('click', (e) => {
switch (this.state) {
@Traineratwot
Traineratwot / postFiles.php
Last active January 13, 2022 07:22
Класс для работы с input type=file
<?php
class PostFile
{
public $name = NULL;
public $path = NULL;
public $ext = NULL;
public $fullName = NULL;
public $type = NULL;
/**
* @var int
@Traineratwot
Traineratwot / jsonValidate.php
Created January 18, 2022 07:40
проверяте является ли строка json tckb да возвращяет json как объект или массив
<?
function jsonValidate($string, $assoc = TRUE, $depth = 1024)
{
try {
if (!is_string($string)) {
return $string;
}
$error = 0;
// decode the JSON data
$string = preg_replace('/[[:cntrl:]]/', '', $string);
<?php
class FTP
{
/*
* Connection
*/
private $connection;
/*
* connectionString
@Traineratwot
Traineratwot / CsvTable.php
Last active February 8, 2022 09:34
Класс для работы с csv. чтение, запись по строкам, запись по колонкам, конвертация в html в массив в сsv
<?php
class CsvTable
{
/* @var string chr(239) . chr(187) . chr(191) */
public $utf8bom;
/* @var string Charset */
public $inputCharset;
public $cache;
public $currentRow = -1;
public $clearRegexp = '@[^[:ascii:]A-я]+@u';
type PermissionName = "geolocation" | "notifications" | "persistent-storage" | "push" | "screen-wake-lock" | "xr-spatial-tracking" | "clipboard-write" | "clipboard-read";
interface MyPermissionDescriptor {
name: PermissionName;
}
export class clipboard {
mode: 'navigator' | 'fallback' | 'notSupport' = 'navigator';
timeLimit: number = 100;
response?: string;
<?php
function name2class($name)
{
$name = preg_replace("@([A-Z])@","_$1",$name);
$name = strtr($name, [
'\\' => '_',
'/' => '_',
'-' => '_',
' ' => '_',
'*' => '_',
0.0.0.0 test.troyan
0.0.0.0 bing.com