Skip to content

Instantly share code, notes, and snippets.

Roman Ožana OzzyCzech

Block or report user

Report or block OzzyCzech

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View commands.sh
# show git conflicts alias
##########################################################################################
git config --global alias.conflicts '!git ls-files -u | cut -f 2 | sort -u'
@OzzyCzech
OzzyCzech / lesscompile.js
Created Jul 30, 2012
Watch dir and perform action on changes
View lesscompile.js
var lessRecompile = function (less, dir) {
console.log('Change :' + less);
var lessc = __dirname + "/deployment/node_modules/.bin/lessc --compress ";
var commands = [
lessc + __dirname + "/src-less/main.less > " + __dirname + "/public/css/main.css",
lessc + __dirname + "/src-less/jqueryui.less > " + __dirname + "/public/css/jqueryui.css"
];
@OzzyCzech
OzzyCzech / change.sql
Created Aug 19, 2012
Wordpress useful queries
View change.sql
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-site.com', 'http://www.new-site.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-site.com','http://www.new-site.com');
UPDATE wp_posts SET post_content = replace(post_content, ' http://www.ancien-site.com ', ' http://www.nouveau-site.com ');
@OzzyCzech
OzzyCzech / normalise-path.php
Created Aug 25, 2012 — forked from thsutton/normalise-path.php
Normalise paths in PHP
View normalise-path.php
<?php
/**
* Normalise a file path string so that it can be checked safely.
*
* Attempt to avoid invalid encoding bugs by transcoding the path. Then
* remove any unnecessary path components including '.', '..' and ''.
*
* @param $path string
* The path to normalise.
* @param $encoding string
@OzzyCzech
OzzyCzech / example.php
Created Nov 26, 2012
Wordpress menu generator
View example.php
// import socialniho menu
$top = new Menu('Top menu');
// page link
if ($page = get_page_by_path('some-page')) {
$top->title('Page');
$top->object_id($page->ID);
$top->object('page');
$top->type('post_type');
$top->save();
@OzzyCzech
OzzyCzech / Console.php
Created Dec 4, 2012
Simple console class
View Console.php
<?php
/**
* Parsing arguments from commandline $argv
*
* @author Roman Ozana <ozana@omdesign.cz>
*/
class Console {
const CROSS = '×';
const DOT = '.';
@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 / Witgets.php
Last active Dec 11, 2015
Registration of the Widgets in Wordpress can be confusing there is simple way how to handle it.
View Witgets.php
<?php
class Widgets {
private $widgets = array();
private $options = array();
public function __construct() {
$this->options = wp_get_sidebars_widgets();
}
@OzzyCzech
OzzyCzech / bootstrap.php
Created Jan 30, 2013
Drobné vylepšení Nette Testeru a výpisu chyby Assert
View bootstrap.php
<?php
\Tester\Assert::$onFailure = function ($message, $expected, $actual) {
$exception = new \Tester\AssertException($message);
$path = NULL;
foreach ($exception->getTrace() as $item) {
// in case of shutdown handler, we want to skip inner-code blocks and debugging calls
$path = isset($item['file']) && substr($item['file'], -5) === '.phpt' ? $item['file'] : $path;
}
if ($path) {
You can’t perform that action at this time.