Skip to content

Instantly share code, notes, and snippets.

View 66Ton99's full-sized avatar
🇺🇦

Ton Sharp 66Ton99

🇺🇦
View GitHub Profile
@66Ton99
66Ton99 / DataBundle.php
Last active August 29, 2015 14:02
DataBundle with Enums
<?php
namespace MyNamespace;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Doctrine\DBAL\Types\Type;
class DataBundle extends Bundle
{
/**
@66Ton99
66Ton99 / Enum.php
Last active August 29, 2015 14:10
OOP enum realisation
<?php
use InvalidArgumentException;
use ReflectionClass;
/**
* Base Enum class
* Require PHP >= 5.3
*
* @author Ton Sharp <66ton99@gmail.com>
@66Ton99
66Ton99 / sendmail_fake.sh
Created September 18, 2011 18:59
Fake sendmail
#!/bin/sh
prefix="/home/mail"
numPath="$prefix/.num"
if [ ! -f $numPath ]; then
echo "0" > $numPath
chmod 0777 $numPath
fi
num=`cat $numPath`
num=$(($num + 1))
@66Ton99
66Ton99 / chain.php
Created September 18, 2011 18:54
Chain of Responsibility
<?php
class Handler
{
protected $next;
protected $id;
protected $limit;
public function getLimit()
{
@66Ton99
66Ton99 / ipconfig.sh
Created September 18, 2011 19:02
Ipconfig for Linux
#! /bin/bash
ifconfig
echo
echo Gateway" "Interface
route -n | awk '/UG/ {printf "%-21s %s\n",$2,$8}'
echo
echo DNS Servers
awk '/nameserver/ {print $2}' /etc/resolv.conf
echo
@66Ton99
66Ton99 / addHashToUrl.js
Created December 21, 2011 13:46
Add hash(anchor) to url without scrolling
/**
* Add hash to url without scrolling
*
* @param String $url - it could be hash or url with hash
*
* @return void
*/
function addHashToUrl($url)
{
if ('' == $url || undefined == $url) {
@66Ton99
66Ton99 / gist:2343223
Created April 9, 2012 12:53
Amazon SQS - Zend_Queue realisation
<?php
/**
* Amazon SQS Queue
*
* @author Ton Sharp <Forma-PRO@66ton99.org.ua>
*/
class Zend_Queue_Adapter_AmazonSQS extends Zend_Queue_Adapter_AdapterAbstract
{
@66Ton99
66Ton99 / gist:2844446
Created May 31, 2012 16:08
Swift memory transport
<?php
/**
* Memory Swift maller transport for unit tests
*
* @package Lib
* @subpackage Swift
* @author Ton Sharp <forma@66ton99.org.ua>
*/
class Swift_MemTransport implements Swift_Transport
@66Ton99
66Ton99 / delete_tables.sql
Last active October 10, 2015 15:58
Deletes all tables in current DB
delimiter $$
create procedure drop_tables_like(pattern varchar(255), db varchar(255))
begin
select @str_tables:=group_concat(table_name)
from information_schema.tables
where table_schema=db and table_name like pattern;
IF @str_tables IS NOT NULL THEN
SET @str_sql := concat('drop table ', @str_tables);
prepare stmt from @str_sql;
@66Ton99
66Ton99 / gist:3833001
Last active October 11, 2015 08:47
It adds ; befor ?>
(['"A-z\)])(?!;) ?\?>
$1;?>