Skip to content

Instantly share code, notes, and snippets.

View Ulv's full-sized avatar
🤔
Working

Ulv Ulv

🤔
Working
View GitHub Profile
@Ulv
Ulv / gist:7887899
Created December 10, 2013 09:20
phpunit tests on git post-update hook (push in master)
#!/usr/bin/env bash
TEST_PATH='/home/ulv/PhpstormProjects/kinetic/oncologytest/tests/'
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
phpunit $TEST_PATH
@Ulv
Ulv / gist:7804028
Created December 5, 2013 11:48
git hooks to run phpunit tests for kinetic
#!/usr/bin/env bash
TEST_GLOB='../../tests/test_*.php'
for f in $TEST_GLOB; do
printf "\n+ Running 'phpunit `basename ${f}`'\n\n"
phpunit $f
rc=$?
if [[ $rc != 0 ]] ; then
@Ulv
Ulv / my_functions.php
Created November 27, 2013 08:21
maxsite cms функция вывода меню
/**
* вывод меню
*
* Пример:
*
* <code>
* if ($menu = mso_get_option('top_menu', 'templates', '')) {
* echo limo_menu_out($menu);
* }
* </code>
@Ulv
Ulv / module.class.php
Created November 26, 2013 12:43
архивация файлов в tar.gz средствами php с блокировкой архива в процессе (простейший mutex)
/**
* архивирует файлы модуля в tar.gz и возвращает имя архива
* Реализована блокировка архива на время архивации (чтобы избежать race)
*
* @return string
*/
public function export()
{
if (is_readable($this->archive_name . '.gz')) {
return $this->archive_name . '.gz';
@Ulv
Ulv / flat.class.php
Created November 20, 2013 11:39
get class constants
public function get_class_constants()
{
$reflect = new ReflectionClass(get_class($this));
return $reflect->getConstants());
}
@Ulv
Ulv / default.php
Created November 16, 2013 11:44
Virtuemart "add to cart" button on category page
<?php // "Add to cart" Button
$this->assignRef('product', $product);
echo $this->loadTemplate('addtocart');
?>
@Ulv
Ulv / _a_clear_log.php
Created November 13, 2013 10:51
masterovoy clear db queries & recalculate stats
$queries = array(
'delete from `s_robots_log` where YEAR(dtlabel) <> YEAR(CURDATE())',
'delete from `s_visits_log` where YEAR(dtlabel) <> YEAR(CURDATE())',
'truncate table `s_robots_stat`',
// 'truncate table `s_visits_stat`',
'truncate table a_ua_ranges',
'truncate table a_log',
'truncate table a_http_error',
// restore stats
@Ulv
Ulv / script.js
Created November 1, 2013 10:55
lazy load images. No jQuery or such req.
window.echo = (function (window, document) {
'use strict';
var Echo = function (elem) {
this.elem = elem;
this.render();
this.listen();
};
var echoStore = [];
@Ulv
Ulv / script.js
Created November 1, 2013 10:54
async load css files. Usage: require('style.css');
function asyncInject(array, fn, delay) {
var i = 0;
window.setTimeout(function iter() {
if (i === array.length) {
return;
}
fn.call(array, array[i], i++);
window.setTimeout(iter, delay);
}, 0);
}
@Ulv
Ulv / script.js
Created November 1, 2013 10:53
disable mouse right click
document.onmousedown = function(event) {
if (event.button == 2) {
return false;
}
}