Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
Hi there...

Roman Ožana OzzyCzech

👋
Hi there...
View GitHub Profile
@OzzyCzech
OzzyCzech / speed.php
Created Dec 7, 2012
Page download speed measurement
View speed.php
<?php error_reporting(E_ALL | E_STRICT);
function format_bytes($size) {
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
return round($size, 2).$units[$i];
}
// Initialize cURL with given url
$url = isset($argv[1]) ? $argv[1] : 'http://www.google.com';
@OzzyCzech
OzzyCzech / Events.php
Last active Jan 4, 2016
Simple event dispatcher with listener prioritizing and filters
View Events.php
<?php
/**
* @author Roman Ozana <ozana@omdesign.cz>
*/
class Events {
/** @var array */
protected $listeners = [];
/**
@OzzyCzech
OzzyCzech / Embed.php
Last active Jan 4, 2016
Simple oEmbed PHP class with request caching visit http://oembed.com/
View Embed.php
<?php
/**
* @author Roman Ozana <ozana@omdesign.cz>
*/
class Embed {
/** @var int */
public static $cacheExpire = 1800; // 30 min
/** @var string */
@OzzyCzech
OzzyCzech / App.php
Last active Jan 3, 2016
Slim PHP application controllers with lazy loading and simple DI
View App.php
<?php
class App extends \Slim\Slim {
public function __construct() {
// database connection
$this->container->singleton(
'database', function () {
return new \DibiConnection(Config::database(), 'bless');
}
@OzzyCzech
OzzyCzech / Generator.php
Last active Dec 28, 2015
Invoice with Latte template
View Generator.php
<?php
namespace invoice;
use Nette\Latte\Engine;
use nx\latte\FileTemplate;
/**
* @author Roman Ozana <ozana@omdesign.cz>
*/
class PdfInvoiceGenerator {
@OzzyCzech
OzzyCzech / app.class.php
Last active Dec 26, 2015
Slim PHP simple "controllers" solution with lazy loading and simple __construct injection from Slim container
View app.class.php
<?php
/**
* Copyright (c) 2013 Roman Ožana (http://omdesign.cz)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*
* @author Roman Ozana <ozana@omdesign.cz>
* @method Homepage()
* @method Homepage_actiom()
View get_daterange_timestamps.php
<?php
/**
* Generates timestamp bounderies for the passed date range name.
*
* @param string $range Date range name.
*
* @return array
*/
function get_daterange_timestamps($range)
@OzzyCzech
OzzyCzech / README.md
Last active Dec 21, 2015
Simple ToggleArea plugin for jQuery or Zepto
View README.md

Usage

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="toggle.js"></script>

HTML code

<a href="#" data-toggle="area" data-area="#area">Toggle control</a>
<div id="area" style="display:none;">
@OzzyCzech
OzzyCzech / plugin.coffee
Created Aug 21, 2013
Basic jQuery or Zepto plugin
View plugin.coffee
#
# $('#element').myPlugin({ param: 'value'});
#
(($, window) ->
"use strict"
class MyPlugin
defaults:
toggle: true