Skip to content

Instantly share code, notes, and snippets.

View christophervalles's full-sized avatar

Christopher Valles christophervalles

View GitHub Profile
@christophervalles
christophervalles / fix_i18n_strings_from_po_file.php
Created May 2, 2012 11:24
Update i18n strings on the source code based on the changes made on a *.po file (Fix wrong sentences, change text, typos, etc). If you developed an app and some sentences on the base language are wrong or must be changed/fixed just create a .po file with
<?php
system('clear');
ini_set('auto_detect_line_endings', TRUE);
$fin = fopen('en.po', 'r');
$change = 0;
while(!feof($fin)){
$line = trim(fgets($fin));
@christophervalles
christophervalles / script.php
Created March 23, 2012 16:28
Get the route name (if exists) that matches the given url in Zend Framework
<?php
$referrer = $this->getRequest()->getServer('HTTP_REFERER');
$request = new Zend_Controller_Request_Http($referrer);
$router = clone $this->getFrontController()->getRouter();
$router->route($request);
$routeName = $router->getCurrentRouteName();
@christophervalles
christophervalles / power-set.php
Created July 6, 2011 08:05
power set of and array
<?php
function pc_array_power_set($array, $limit){
$subset = array();
$results = array(array());
foreach ($array as $element){
foreach ($results as $combination){
$result = array_merge(array($element), $combination);
array_push($results, $result);