Skip to content

Instantly share code, notes, and snippets.

View luads's full-sized avatar

Luã de Souza luads

  • Immutable
  • Sydney, Australia
View GitHub Profile
@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;
@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 / 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 / DateSinceExtension.php
Created April 12, 2013 20:59
Extensão pro twig exibir quanto tempo passou entre uma data qualquer e a data atual
<?php
namespace Acme\CoreBundle\Twig;
class DateSinceExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
'date_since' => new \Twig_Filter_Method($this, 'dateSince'),
@luads
luads / states.yml
Created April 18, 2013 18:03
YAML com a lista de estados brasileiros
parameters:
states:
AC:
code: AC
state: 'Acre'
AL:
code: AL
state: 'Alagoas'
AM:
code: AM
@luads
luads / post-receive.py
Created December 16, 2013 19:55
A post-receive hook to interact with asana tasks, refering the commits with a link to gitlist.
#!/usr/bin/env python
"""
To use this you have to include the task ID on the commit message.
Example: Fixing typo, #9283764018
You can as well close a task within the commit message.
Example: Improving the docs, closes #9823761989
"""
<snippet>
<content><![CDATA[echo "<pre>"; print_r (${1:variable}); die("</pre>");]]></content>
<tabTrigger>dv</tabTrigger>
<scope>source.php</scope>
<description>PHP: debug with print_r</description>
</snippet>
@luads
luads / playlist-gmusic.py
Last active November 28, 2016 02:30 — forked from Timmmm/lastfm_to_gmusic.py
Imports any playlist into gmusic
#!/usr/bin/env python
# Import any playlist (within the script) to Google Music All Access playlist.
#
# Based on Tim Hutt's script:
# https://gist.github.com/Timmmm/6572592
#
# Instructions:
# 1. Write the playlist down to the file
# 2. Install `gmusicapi` using `pip`: `pip install gmusicapi`
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
class Php71Xdebug < AbstractPhp71Extension
init
desc "Provides debugging and profiling capabilities."
homepage "http://xdebug.org"
url "https://pecl.php.net/get/xdebug-2.4.1.tgz"
sha256 "23c8786e0f5aae67b1e5035972bfff282710fb84c483887cebceb8ef5bbdf8ef"
head "https://github.com/xdebug/xdebug.git"