Skip to content

Instantly share code, notes, and snippets.

View midnai's full-sized avatar

Jhosbel Aguilar midnai

View GitHub Profile
// in your javascript file ...
$(document).ready(function() {
$('#send').click(function(){
if($("#email").val().indexOf('@', 0) == -1 || $("#email").val().indexOf('.', 0) == -1) {
alert('El correo electrónico introducido no es correcto.');
return false;
}
@midnai
midnai / Symfony 2.3 Get All Form Errors.php
Last active August 29, 2015 14:07
Symfony 2.3 Get All Form Errors
<?php
By yapro
File Service: /src/Intranet/OrgunitBundle/Resources/config/services.yml
services:
form_errors:
class: Intranet\OrgunitBundle\Form\FormErrors
@midnai
midnai / change_password.php
Last active August 29, 2015 14:08
change password in symfony2.3 using fosuserbundle
// in you submit action
$userManager = $this->container->get('fos_user.user_manager');
$user->setPlainPassword($password);
$userManager->updatePassword($user);
..... // perform some action
$em->flush();
@midnai
midnai / form_login.php
Created November 19, 2014 23:56
Symfony2 Form Login: Rename fields name atributte's
changing your firewall to match this:
security:
firewalls:
my_firewall:
pattern: ^/
form_login:
username_parameter: "form_name[username_field_name]"
password_parameter: "form_name[password_field_name]"
csrf_parameter: "form_name[_token]"
csrf_provider: form.csrf_provider
<?php
// src/Acme/FormsTutorialBundle/AcmeFormsTutorialBundle.php
namespace Acme\FormsTutorialBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AcmeFormsTutorialBundle extends Bundle
{
}
@midnai
midnai / diference_date.php
Created December 2, 2014 06:15
Número de meses entre dos fechas en PHP
$fechainicial = new DateTime('2012-01-01');
$fechafinal = new DateTime('2013-01-01');
$diferencia = $fechainicial->diff($fechafinal);
// El método diff nos devuelve un objeto del tipo DateInterval,
// que almacena la información sobre la diferencia de tiempo
// entre fechas (años, meses, días, etc.).
@midnai
midnai / empty_isset_count.php
Created May 14, 2015 04:06
Using PHP's empty() Instead of isset() and count()
//Work with data arrays in PHP
//A way to pass information around or store information in sessions.
//When you work with these, you can't always assume that all properties are defined.
//I had some conditional logic code in PHP that was only supposed to execute if an array contained any values:
$data = array(
'text' => array( 'hello', 'world' ),
'numbers' => array( 43, 2, 55 )
);
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@midnai
midnai / vim_basic_config.txt
Last active August 29, 2015 14:25
Configuring Vim on Mac OS X
Verify and create directories:
You’ll need to create directories for the following: backups, colors, swaps and undo.
You can download for example your favorite color schema by vimninjas.com and paste in the relevant scheme file ~/.vim/colors/
$cd ~/.vim;
$mkdir backups;
$mkdir colors;
$mkdir swaps;
$mkdir undo;
(function($) {
$.fn.getHiddenDimensions = function(boolOuter) {
var $item = this;
var props = { position: 'absolute', visibility: 'hidden', display: 'block' };
var dim = { 'w':0, 'h':0 };
var $hiddenParents = $item.parents().andSelf().not(':visible');
var oldProps = [];
$hiddenParents.each(function() {
var old = {};