Skip to content

Instantly share code, notes, and snippets.

@OzzyCzech
OzzyCzech / generateMenu.php
Created Apr 4, 2014
Simple way how to structured list from RecursiveDirectoryIterator
View generateMenu.php
<?php
function generateMenu(\RecursiveIterator $iterator, $level = 0) {
$iterator->rewind();
$output = '';
while ($iterator->valid()) {
$output .= '<li>';
@OzzyCzech
OzzyCzech / jquery-plugin.coffee
Last active Aug 29, 2015
JQuery Plugins : Coffee script Class Boilerplate
View jquery-plugin.coffee
do($ = jQuery, window = window) ->
class MyPlugin
options:
some: null
options: null
constructor: (@el, @options) ->
@options = $.extend({}, @options, options)
@OzzyCzech
OzzyCzech / index.md
Last active Aug 29, 2015
Pár poznámek k odesílání emailů
View index.md

Poznámky k odesílání emailů

Co vás čeká

Bolestivá cesta fragmentace trhu, velikosti zařízení, bugujících aplikací. Občas šílené řešení

Bulletproof email buttons design:

	<div><!--[if mso]>
@OzzyCzech
OzzyCzech / menu.js
Created Mar 24, 2014
Node.js nested menu generation from list of files
View menu.js
// console.log('/this/will/be/path'.);
var dirname = require('path').dirname;
var basename = require('path').basename;
var normalize = require('path').normalize;
var resolve = require('path').resolve;
var writeFile = require('fs').writeFile;
var extname = require('path').extname;
var slug = require('speakingurl');
//var _ = require('underscore')._;
@OzzyCzech
OzzyCzech / CountEmail.php
Created Feb 3, 2014
Wordpress send email statistics made easy and simple with Google Graph
View CountEmail.php
<?php
/**
* @author Roman Ožana <ozana@omdesign.cz>
*/
class CountEmail {
/**
* @return MailFrom
*/
public static function init() {
@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');
}
View convert.php
<?php
$data = json_decode(file_get_contents(__DIR__ . '/currency.json'));
$code = var_export((array)$data, true);
// add gettext function call
$code = preg_replace("/'name' => '(.+)'/", "'name' => __('$1')", $code);
$code = preg_replace("/'name_plural' => '(.+)'/", "'name' => __('$1')", $code);
// save PHP code
$code = "<?php\n return " . preg_replace('/stdClass::__set_state/', '(object)', $code) . ';';
file_put_contents(__DIR__ . '/currencies.locale.php', $code);
@OzzyCzech
OzzyCzech / html2pdf.js
Created Jan 10, 2014
Html 2 PDF using Phantom.js
View html2pdf.js
// html2pdf.js
var page = new WebPage();
var system = require("system");
// change the paper size to letter, add some borders
// add a footer callback showing page numbers
page.paperSize = {
format: "A4",
orientation: "portrait",
footer: {
You can’t perform that action at this time.