Skip to content

Instantly share code, notes, and snippets.

View luads's full-sized avatar

Luã de Souza luads

  • Sydney, Australia
View GitHub Profile
@luads
luads / PasswordService.php
Created March 28, 2013 20:06
Authenticate an external app through a Symfony2 + FOSUserBundle database
<?php
class PasswordService
{
public function __construct($algorithm = 'sha512', $encodeHashAsBase64 = true, $iterations = 5000)
{
$this->algorithm = $algorithm;
$this->encodeHashAsBase64 = $encodeHashAsBase64;
$this->iterations = $iterations;
}
@luads
luads / gist:3908156
Last active October 11, 2015 19:28
Generate a GUID with PHP
<?php
function generateGuid()
{
$hash = strtoupper(hash('ripemd128', uniqid('', true) . md5(time() . rand(0, time()))));
$guid = '{'.substr($hash, 0, 8).'-'.substr($hash, 8, 4).'-'.substr($hash, 12, 4).'-'.substr($hash, 16, 4).'-'.substr($hash, 20, 12).'}';
return $guid;
}
@luads
luads / gist:2239878
Created March 29, 2012 16:55
Show product attributes in magento wishlist
<?php
// the $item var is a Mage_Wishlist_Model_Item instance, used in the wishlist pview.html
function getOptionsWithValues()
{
$attributes = $item->getOptionByCode('attributes')->getValue();
if (!$attributes)
{
return null;