Skip to content

Instantly share code, notes, and snippets.

View gskema's full-sized avatar

Gytis Šk. gskema

  • Kaunas, Lithuania
View GitHub Profile
@gskema
gskema / loading-overlay.css
Last active November 28, 2016 15:45
CSS loading overlay with a spinner
/* *spinner image not included */
.loading {
position: relative;
pointer-events: none;
cursor: not-allowed;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
@gskema
gskema / blockuserinfo.php
Last active August 29, 2015 14:20
Overrding PrestaShop module instance class
<?php
if (!defined('_PS_VERSION_'))
exit;
class BlockUserInfoOverride extends BlockUserInfo
{
public function hookDisplayNav($params)
{
return '<div class="header_user_info"><a>Test</a></div>';
@gskema
gskema / blocktopmenu.php
Created May 10, 2015 07:56
Unextendable class methods
class BlockTopMenu extends Module
{
private $_menu = '';
private $_html = '';
private $user_groups;
...
private function getMenuItems(){ ... }
@gskema
gskema / blockuserinfo.php
Created May 10, 2015 08:21
Minor method modification: 'company_name'
<?php
if (!defined('_PS_VERSION_'))
exit;
class BlockUserInfoOverride extends BlockUserInfo
{
public function hookDisplayTop($params)
{
if (!$this->active)
@gskema
gskema / blockuserinfo.php
Created May 10, 2015 08:28
Clean method override
<?php
if (!defined('_PS_VERSION_'))
exit;
class BlockUserInfoOverride extends BlockUserInfo
{
public function hookDisplayTop($params)
{
$this->smarty->assign(array(
@gskema
gskema / db.php
Created September 1, 2015 11:15
PHP PDO bulk INSERT
<?php
class Db
{
public function batchInsert($table, array $rows, array $columns = array())
{
// Is array empty? Nothing to insert!
if (empty($rows)) {
return true;
}
@gskema
gskema / index.html
Last active December 5, 2015 18:32
Bootstrap 3 Numeric Up and Down control (spinbox, spinner)
<div class="spinbox" data-min="1" data-max="10" data-step="2">
<input class="form-control spinbox-input" type="text" value="1">
<div class="spinbox-buttons">
<button class="spinbox-up btn btn-default btn-xs" type="button">+</button>
<button class="spinbox-down btn btn-default btn-xs" type="button">-</button>
</div>
</div>
<script type="text/javascript">
// jQuery must be available before binding events
@gskema
gskema / list-grid.html
Last active December 27, 2017 20:40
Bootstrap 3 varied height columns
<style type="text/css">
/*
* Allows to usage of <ul> as .row and <li> as .col-**-*
* Benefit of using <li> is that the column can be of varied height,
* unlike when using div.row - columns collapse when heights are different.
* The tricky part is to eliminate whitespaces between <li></li> tags.
*
* Usage: <ul class="list-grid row">
* <li class="col-md-3">...</li>
*
@gskema
gskema / convert.php
Created February 4, 2016 12:53
Integer number in Lithuanian words
<?php
/**
* Converts an integer number to a word in Lithuanian language.
*
* @param int $number Integer number to be converted into words
* @param array|bool $units Units array like array(0 => šimtas, 1 => šimtai, 2 => šimtų);
* @param bool $one If false, word "vienas" is omitted
* @return string
*/
@gskema
gskema / paginator.php
Created February 4, 2016 12:54
Binary pagination generator
<?php
/**
* Generates a pagination array
*
* @param int $total_items
* @param int $page_size
* @param int $current_page
* @return array $pagination
*/