Skip to content

Instantly share code, notes, and snippets.

View diloabininyeri's full-sized avatar

Dılo abinin yeri diloabininyeri

View GitHub Profile
@diloabininyeri
diloabininyeri / index.html
Created December 28, 2023 10:10
An example of php socket server and js socket client
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebSocket Client</title>
</head>
<body>
<button onclick="sendCalculation()">Calculate</button>
<div id="result"></div>
@diloabininyeri
diloabininyeri / client.php
Created December 28, 2023 09:45
simple php socket server and client
<?php
$date = date('Y-m-d H:i:s');
$socket_client = stream_socket_client('tcp://localhost:8080');
while (true) {
fwrite($socket_client, "son gelen $date");
echo fread($socket_client, 1024).PHP_EOL;
sleep(1);
}
@diloabininyeri
diloabininyeri / test.php
Created December 16, 2023 05:08
Bitwise operations permission system example in PHP
class Permission
{
private const int READ = 10;
private const int WRITE = 20;
private const int DELETE = 40;
@diloabininyeri
diloabininyeri / test.php
Created March 22, 2023 11:32
The an example observer design pattern in php
<?php
interface Subscriber
{
public function handle(Blog $blog): void;
}
trait ObserveAble
{
@diloabininyeri
diloabininyeri / mysql.conf
Created March 15, 2023 08:52
logstash input mysql and output mysql
input {
jdbc {
jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/database_name"
jdbc_user => "admin"
jdbc_password => "admin"
jdbc_driver_library => "/home/log-stash/drivers/mysql-connector-java-8.0.25.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
statement => "SELECT * FROM my_table_input WHERE id > :sql_last_value ORDER BY id ASC limit 1"
tracking_column => "id"
tracking_column_type => "numeric"
@diloabininyeri
diloabininyeri / route.php
Last active March 3, 2023 14:38
I have sampled how Laravel route architecture is in the simplest way, after this example you can make a very advanced route yourself
<?php
class RouteManager
{
private string $middleware;
private string $name;
@diloabininyeri
diloabininyeri / exception.php
Last active February 28, 2023 09:24
the advance handler exception class in php
<?php
class ExceptionHandler
{
private static array $exceptionHandlers = [];
public function __construct()
{
set_exception_handler(/**
@diloabininyeri
diloabininyeri / http_pool.php
Last active February 22, 2023 14:03
an example of how we can create a concurrent http pool using multi curl in php...
class Response
{
public function __construct(private string $body, private CurlHandle $curlHandle)
{
}
public function body(): string
{
return $this->body;
}
@diloabininyeri
diloabininyeri / curl.php
Last active February 17, 2023 16:26
php curl php http request class example
class Http
{
/**
* @var CurlHandle|false $curl
*/
private CurlHandle|false $curl;
private array $curlArray = [];
private string|false $response;
@diloabininyeri
diloabininyeri / xml_builder.php
Created February 15, 2023 13:22
The an advance xml builder class
<?php
class Xmlbuilder
{
private SimpleXMLElement $element;
public function __construct(SimpleXMLElement $simpleXMLElement = new SimpleXMLElement('<root/>'))