Skip to content

Instantly share code, notes, and snippets.

@sblmasta
sblmasta / getRandomDoctrineItem.php
Created November 25, 2015 11:59 — forked from Thinkscape/getRandomDoctrineItem.php
Get random item from Doctrine2 repository
<?php
use Doctrine\ORM\EntityManager;
/**
* Retrieve one random item of given class from ORM repository.
*
* @param EntityManager $em The Entity Manager instance to use
* @param string $class The class name to retrieve items from
* @return object
*/
@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
@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 / 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 %}
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
<?php
namespace cms\entity;
class Category
{
protected $id;
protected $left = 0;
protected $right = 1;