Skip to content

Instantly share code, notes, and snippets.

View 66Ton99's full-sized avatar
🇺🇦

Ton Sharp 66Ton99

🇺🇦
View GitHub Profile
@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 / 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 / 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;?>
@66Ton99
66Ton99 / drop_data.sql
Last active December 14, 2015 02:38
Drop all data in the current DB
-- Server version 5.5.20
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@66Ton99
66Ton99 / DateTime.php
Last active May 16, 2024 05:31
DateTime
<?php
namespace MyNamespace;
/**
* @author Ton Sharp <66Ton99@gmail.com>
*/
class DateTime extends \DateTime
{
/**
* @param int|null $year