Skip to content

Instantly share code, notes, and snippets.

View kobus1998's full-sized avatar
😳
-10x programmer

Kobus kobus1998

😳
-10x programmer
View GitHub Profile
@kobus1998
kobus1998 / something.php
Created July 18, 2018 13:50
PHP Validate mail body
<?php
/**
* Make sure lines are right length in mail body
* @param string mail body
* @param int max line length (default 68)
* @param bool only return bool instead of modified body (default false)
* @return string|bool validated body
*/
function validateMailBody($sBody, $iMaxLen = 68, $bReturnBool = false)
@kobus1998
kobus1998 / FlashMsg.php
Created May 9, 2018 14:32
Flash messages
<?php
class FlashMsg {
const SUCCESS = 'success';
const WARNING = 'warning';
const ERROR = 'error';
/**
* Static msgs holder
@kobus1998
kobus1998 / Enum.php
Created April 30, 2018 15:04
Enum in php
<?php
class Enum {
private static $constCacheArray = NULL;
private static function getConstants() {
if (self::$constCacheArray == NULL) {
self::$constCacheArray = [];
}
$calledClass = get_called_class();
@kobus1998
kobus1998 / Iter.php
Created April 20, 2018 13:59
Iterator
<?php
class Iter {
private $arr;
private $result;
public function __construct($array) {
$this->arr = $array;
}
@kobus1998
kobus1998 / index.php
Created March 22, 2018 11:34
Modify all html and xml nodes
<?php
$p = "/<\s*[^\/].*\s*>/";
$str = "
<div>
<p>
Tessttst jhsdfb skfsdk
</p>
</div>
@kobus1998
kobus1998 / index.php
Created March 21, 2018 15:52
Event dispatcher
<?php
class Event
{
public static $events;
public function __construct()
{
self::$events = [];
@kobus1998
kobus1998 / FizzBuzz.rs
Created March 9, 2018 10:33
Rust fizzbuzz
fn main() {
let max: i32 = 101;
let mut l: Vec<String> = Vec::new();
for i in 0..max
{
l.push(fizz_buzz(i));
}
@kobus1998
kobus1998 / index
Created March 8, 2018 14:27
url match
(?:(?<http>http(?:s*)):\/\/(?<host>staging.roomraccoon.com))*(?<path>(?:\/\w*)*)(?<qs>(?:\?\w*=\w*)(?:\&\w*=\w*))
@kobus1998
kobus1998 / index.php
Created March 8, 2018 12:53
array to xml
<?php
$xml = [
"payments" => [
[
"amount" => "100",
"initials" => "ih"
],
[
"amount" => "1000",
<?php
class Benchmark
{
public $time;
private $startTime;
private $stopTime;
public function go($callback)
{