Skip to content

Instantly share code, notes, and snippets.

View neonxp's full-sized avatar
🤖
Code to live, live to code

Alex neonxp

🤖
Code to live, live to code
View GitHub Profile
<?php
/**
* Simple DI container for projects with legacy code without PSR-0 classes and namespaces
* Usage:
* require_once('DIC/Container.php');
* $c = new Container();
* $c->get('example')->method();
*/
class Container {
@neonxp
neonxp / gist:4134350
Created November 23, 2012 07:17
Google token generator
<?
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@neonxp
neonxp / gist:3898225
Last active October 11, 2015 18:07
Date check for d.m.Y format
/^(((([0-2][0-9]|30)\.(04|06|09|11))|(([0-2][0-9]|31)\.(01|03|05|07|08|10|12))|(([0-2][0-9])\.02))\.[0-9](0|4|8)((0|2|4|6|8)(0|4|8)|(1|3|5|7|9)(2|6)))|(((([0-2][0-9]|30)\.(04|06|09|11))|(([0-2][0-9]|31)\.(01|03|05|07|08|10|12))|(([0-2][0-8])\.02))\.!([0-9](0|4|8)((0|2|4|6|8)(0|4|8)|(1|3|5|7|9)(2|6))))$/
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
/**
* Name: Nice Menu
* Version: 0.2
* Author: Marcell Jusztin - http://www.marcelljusztin.com
* Description: A simple, elegant, colorful, CSS3 animated menu
* Tags: css3, animation, menu, simple, elegant, colourful
* License: http://creativecommons.org/licenses/by-sa/3.0/
*
* Changelog v0.2:
* - Changed animation to support percentage, so there is no need to update values one-by-one
@neonxp
neonxp / gist:2593196
Created May 4, 2012 08:10
Simple config file parser
<?php
function parseFile($file) {
$matches = array();
$pattern = '/(.+?)\s+(.+?)\n/';
preg_match_all($pattern, file_get_contents($file), $matches);
$matches[2] = array_map(function($value) { preg_match_all('/\G(?:^|,)(?:"([^"]*+(?:""[^"]*+)*+)"|([^",]*+))/x', $value, $ret); return (count($ret[2])>1)?$ret[2]:$ret[2][0]; } , $matches[2]);
return array_combine($matches[1], $matches[2]);
}
print_r(parseFile('input.txt'));
@neonxp
neonxp / getExtByMimeType.php
Created March 5, 2012 14:01
Rocksolid function for get extension of file by it mime type
<?php
function getExtByMimeType($mime) {
$known_files = array(
'/etc/mime.types',
'/etc/httpd/mime.types',
'C:\Program Files\Apache Group\Apache\conf\mime.types'
); /* If mime type file of your system not listed here, please add it path here */
$extensionFile = null;
@neonxp
neonxp / gist:1912279
Created February 26, 2012 02:08
HTTP codes
<?php
$http_statuses = array (
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
@neonxp
neonxp / gist:1616744
Created January 15, 2012 18:48
GIT Wizardy
1 Введение
В своей прошлой заметке я постарался осветить в общих чертах стиль работы с
распределенной системой контроля версий git и указать на отличия по сравнению с
классическими централизованными СКВ. Целью было прежде всего обобщение опыта
работы с системой без упоминания тонкостей синтаксиса отдельных команд.
Данный же топик задумывался как непосредственное введение в работу с git, нечто
среднее между tutorial и обобщенной справкой, до которого все же рекомендуется
@neonxp
neonxp / gist:1616737
Created January 15, 2012 18:45
Боевой коктейль
На форуме, посвященном творчеству Юрия Никитина, задали вопрос: как быстро придти в норму, если чай и кофе уже не
помогают проснуться? Классическая ситуация: 3 часа ночи, у вас подготовка диплома или ночная смена на работе в самом
разгаре, а вы уже не работник, а обыкновенный зомби. 2-х литровый чайник чая или кофе внутри вас, сердце выпрыгивает из
груди, каждые 15 минут ползаете в туалет, а глаза уже не открываются. Знакомо? Как привести себя в норму за 5-7 минут без
медикаментов и энергетиков?
Предупреждаю заранее: не смейтесь, методика проверена годами и многими людьми, очень действенна и проста для изучения.
Перед боем, спортивными соревнованиями и просто в экстренных случаях, методика просто незаменимая. Только не