Skip to content

Instantly share code, notes, and snippets.

$.fn.extend({
limitText: function(config){
$(this).after('<div id="counter">Limit znaków: <span></span></div>');
var limit = typeof(config.limit) == 'undefined' ? this.attr('maxlength') : config.limit;
var counter_hook = typeof(config.counter) == 'undefined' ? '#counter' : config.counter;
$(counter_hook).data('value', limit);
$(counter_hook).find('span').html(limit);
<?php
namespace cms\entity;
class Category
{
protected $id;
protected $left = 0;
protected $right = 1;
@sblmasta
sblmasta / ISPConfig_Postfixadmin.php
Created October 29, 2014 14:02
Convert mailboxes from ISPConfig postfix to Postfixadmin structure.
<?php
$db = new PDO('mysql:host=localhost;dbname=postfix;charset=utf8', 'root', 'admin');
$stmt = $db->query("SELECT * FROM mail_user");
foreach( $stmt->fetchAll(PDO::FETCH_ASSOC) as $row )
{
$email = $row['email'];
$login = explode('@',$email)[0];
$domain = explode('@',$email)[1];
$(function(){
$('.arrayToString input[type="checkbox"]').on('click', function(){
var t = $(this);
var inputData = $('#' + t.data('input'));
var list = inputData.val().split(',').filter(function() { return true; });
var value = t.val();
var elem = list.indexOf(value);
if( $(this).prop('checked') )
{
@sblmasta
sblmasta / gist:5511ee1e91d3e80fea31
Created February 24, 2015 21:39
PHP 5.5 ./configure command
./configure --prefix=/opt/php/5.5 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-gd --with-pgsql=/usr/lib/postgresql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=lib --enable-ftp --with-imap=/usr/local/imap-2007f --with-imap-ssl --with-kerberos --with-gettext --with-xsl --enable-fpm --enable-opcache
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@zencode.pl
DocumentRoot "/Users/sbl/www"
ServerName localhost
ServerAlias localhost
ErrorLog "/Users/sbl/www/logs/error.log"
CustomLog "/Users/sbl/www/logs/access.log" common
@sblmasta
sblmasta / collection_widget.twig
Last active September 11, 2015 16:20 — forked from cowlby/collection_widget.twig
Customizing form collections in Symfony2
{% block collection_widget %}
{% spaceless %}
<div class="collection">
{% if prototype is defined %}
{% set attr = attr|merge({'data-prototype': block('collection_item_widget') }) %}
{% endif %}
<div {{ block('widget_container_attributes') }}>
{{ form_errors(form) }}
<ul>
{% for rows in form %}
@sblmasta
sblmasta / nginx.conf
Created October 5, 2015 19:50 — forked from denys281/nginx.conf
Symfony2 nginx virtual host (php-fpm)
server {
listen 80;
# Server name being used (exact name, wildcards or regular expression)
server_name mysite.com;
client_max_body_size 20M;
# Document root, make sure this points to your Symfony2 /web directory
root /home/user/sites/mysite.com/web;
@sblmasta
sblmasta / validate-selectize-fields.js
Created November 2, 2015 15:25 — forked from yannleretaille/validate-selectize-fields.js
How to validate selectize.js comboboxes with the jQuery validation plugin
//How to validate selectize.js comboboxes with the jQuery validation plugin
//selectize.js: http://brianreavis.github.io/selectize.js/ (brianreavis/selectize.js)
//http://jqueryvalidation.org (jzaefferer/jquery-validation)
//configure jquery validation
$("#commentForm").validate({
//the default ignore selector is ':hidden', the following selectors restore the default behaviour when using selectize.js
//:hidden:not([class~=selectized]) | selects all hidden elements, but not the original selects/inputs hidden by selectize
//:hidden > .selectized | to restore the behaviour of the default selector, the original selects/inputs are only validated if their parent is visible
//.selectize-control .selectize-input input | this rule is not really necessary, but ensures that the temporary inputs created by selectize on the fly are never validated
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[isamchk]
key_buffer = 16M
[mysqld]
basedir = /usr
datadir = /var/lib/mysql