Skip to content

Instantly share code, notes, and snippets.

View Sergic's full-sized avatar

Sergey Gerdel Sergic

View GitHub Profile
@Sergic
Sergic / StringDateExtension.php
Created September 4, 2012 17:49
date twig extension (today, yesterday, tomorrow)
<?php
/*
* This file is part of the INB application.
*
* (c) Sergey Gerdel <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@Sergic
Sergic / gist:3659782
Created September 6, 2012 19:38
Symfony2 get form errors. Какие есть ошибки в форме и полях.
/*зы. эт просто памятка. для меня и всех. если юзать форму для аякса и прочего.
уже в который раз попадаюсь на пару ошибок...
мы сделали bind->request для формы, а функция isValid() возвращает false.*/
/*1. проверить глобальные ошибки*/
$form->getValues()
/*2. проверить каждое поле*/
foreach ($form as $form_field){
$form_field->getErrors(); // глянуть что тут...
}
@Sergic
Sergic / placeholder.js
Created September 7, 2012 00:14
ie8 html5 placeholder (jquery)
$('input[placeholder]').each(function(){
var input = $(this);
$(input).val(input.attr('placeholder'));
$(input).focus(function(){
if (input.val() == input.attr('placeholder')) {
input.val('');
}
@Sergic
Sergic / uri.js
Created September 8, 2012 09:03 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@Sergic
Sergic / password_hashing_api.md
Created September 12, 2012 19:16 — forked from ikwattro/password_hashing_api.md
The new Secure Password Hashing API in PHP 5.5

The new Secure Password Hashing API in PHP 5.5

The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:

Why do we need a new API?

Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).

# -*- mode: ruby -*-
# vi: set ft=ruby :
# David Lutz's Multi VM Vagrantfile
# inspired from Mark Barger's https://gist.github.com/2404910
boxes = [
{ :name => :web, :role => 'web_dev', :ip => '192.168.33.1', :ssh_port => 2201, :http_fwd => 9980, :cpus =>4, :shares => true },
{ :name => :data, :role => 'data_dev', :ip => '192.168.33.2', :ssh_port => 2202, :mysql_fwd => 9936, :cpus =>4 },
{ :name => :railsapp, :role => 'railsapp_dev', :ip => '192.168.33.3', :ssh_port => 2203, :http_fwd => 9990, :cpus =>1}
]
@Sergic
Sergic / email.php
Created June 12, 2013 11:39
email validation php
<?php
filter_var($email, FILTER_VALIDATE_EMAIL);
<?php
$collection = new Doctrine\Common\Collection\ArrayCollection();
// add objects to the collection that contain a getCreated method returning a DateTime instance
$iterator = $collection->getIterator();
$iterator->uasort(function ($first, $second) {
if ($first === $second) {
VERSION=0.20.6
sudo apt-get update
sudo apt-get install openjdk-6-jdk
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$VERSION.deb
sudo dpkg -i elasticsearch-$VERSION.deb
# be sure you add "action.disable_delete_all_indices" : true to the config!!