Skip to content

Instantly share code, notes, and snippets.

Alex Babkov ababkov

  • Rex Software
Block or report user

Report or block ababkov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View _.md
View _.md
@ababkov
ababkov / php-expanded-glob
Created Sep 3, 2015
Expand /**/ in a php glob expression to simulate nested folder expressions (which otherwise aren't supported for some reason)
View php-expanded-glob
function expandExpression($path,$depth=3,$marker="/**/"){
$e_path = explode($marker,$path);
if( count($e_path) > 2 ){
throw new \InvalidArgumentException("Only one instance of '{$marker}' is supported per expression.");
} elseif( count($e_path) < 2 ){
return $e_path;
}
$base_path = $e_path[0];
$sub_path = $e_path[1];
@ababkov
ababkov / monolog-timezone-hack.php
Last active Aug 29, 2015
Force the Monolog Logger to use non default timezone
View monolog-timezone-hack.php
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
$example_timezone = "Australia/Brisbane";
$logger = new Logger($name);
@ababkov
ababkov / reaxml-read-current-listing-addresses.php
Created May 3, 2014
REAXML - Read current listing addresses
View reaxml-read-current-listing-addresses.php
<?php
$xml_file_path = dirname(__FILE__)."/reaxml.xml";
$csv_file = dirname(__FILE__)."/current-listings.csv";
$xmlr = new XMLReader();
$opened = $xmlr->open($xml_file_path);
if( !$opened ){
throw new Exception("WARN: Could not open XML file '{$xml_file_path}'. Please check it exists and is valid.");
}
@ababkov
ababkov / json-to-csv.php
Last active Aug 29, 2015
Convert JSON file to CSV
View json-to-csv.php
<?php
$json = json_decode(file_get_contents("source.json"),true);
$fh = fopen("target.csv","w+");
fputcsv($fh,array_keys(current($json)));
foreach($json as $row){
fputcsv($fh,$row);
}
You can’t perform that action at this time.