Skip to content

Instantly share code, notes, and snippets.

View Ulv's full-sized avatar
🤔
Working

Ulv Ulv

🤔
Working
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / pre-commit
Created February 25, 2014 09:33
git pre-commit hook - backup mysql database on every commit
#!/usr/bin/bash
# бэкап mysql базы при каждом коммите
FILENAME=/home/www/intinity/klumbariy/db/`date +%d-%m-%Y-%H-%I-%S`.mysql
mysqldump intinity_klumba -u klumba \
-p2UDRyHqedqnSfFfW > ${FILENAME}
git add $FILENAME
@Ulv
Ulv / slider.php
Created May 9, 2014 08:35
joomla 3: select last 6 featured articles
/*
*last 6 featured articles
*/
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*')
->from($db->quoteName('#__content'))
->where($db->quoteName('featured') . ' = 1 ')
->order('created DESC');
@Ulv
Ulv / klumba_category_slider.php
Created May 25, 2014 08:39
joomla: fetch last 4 articles from current category subcategories
/*
* get subcategory ids
*/
$catID = $this->category->id;
$categories = JCategories::getInstance('Content');
$cat = $categories->get($catID);
$children = $cat->getChildren();
$children = array_map(function($el) {
return (array)$el;
@Ulv
Ulv / app.coffee
Created May 28, 2014 08:18
angularjs, coffeescript: app dataService (with promise)
# Usage examples:
#
# dataService.getTree().then((response)->
# if response
# $scope.list = response.data
#
# dataService.saveTree(nodeData)
.service "dataService", ($http) ->
delete $http.defaults.headers.common["X-Requested-With"]