Skip to content

Instantly share code, notes, and snippets.

View scodx's full-sized avatar
🏠
Working from home

Oscar Sánchez scodx

🏠
Working from home
View GitHub Profile
$select.children().filter(':selected');
$select.children(':selected');
$("#yourdropdownid option:selected").text();
@scodx
scodx / timestamp search.php
Last active August 29, 2015 14:07
snippet para obtener el timestamp para buscar en una bd
$from = mktime(0, 0, 0, $month_selected, 1, $year);
$to = mktime(23, 59, 59, ($month_selected + 1), 0, $year);
// random number between 0 and 100... :)
var randomNumber = Int(arc4random_uniform(UInt32(100)))
-- Poner nombres (dates y demas) en español..
SET lc_time_names = 'es_MX';
function sanitizeString($string)
{
$string = trim($string);
$string = str_replace(
array('á', 'à', 'ä', 'â', 'ª', 'Á', 'À', 'Â', 'Ä'),
array('a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A'),
$string
);

#untrack and retrack files locally in git edit: .git/info/exclude

untrack: $ git update-index --assume-unchaged filename

retrack: git update-index --no-assume-unchanged filename

How to login a user programatically in Symfony2

http://hasin.me/2013/10/27/how-to-login-a-user-programatically-in-symfony2/

Sometime, you may need to log in an user manually from code, instead of generic form based log in. To do it, you need to use Two Security component “UsernamePasswordToken” and “InteractiveLoginEvent”. We will also use another exception object “UsernameNotFoundException” if the user is not found.

use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;

Git force pull to overwrite local files

git fetch --all
git reset --hard origin/master
git pull origin master