Skip to content

Instantly share code, notes, and snippets.

View peterlozano's full-sized avatar

Pedro Lozano peterlozano

View GitHub Profile
@peterlozano
peterlozano / PHP measure code time
Created February 8, 2011 11:01
Measure the time spent in a piece of code. Extracted from Drupal database layer.
<?php
list($usec, $sec) = explode(' ', microtime());
$timer = (float)$usec + (float)$sec;
//
// YOUR CODE HERE
//
list($usec, $sec) = explode(' ', microtime());
@peterlozano
peterlozano / XHPROF MEASURE
Last active September 25, 2015 08:27
Enable and dump xhprof
$path = '/usr/share/php';
include_once $path . '/xhprof_lib/utils/xhprof_lib.php';
include_once $path . '/xhprof_lib/utils/xhprof_runs.php';
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
// YOUR CODE HERE
$namespace = 'app_namespace';
$xhprof_data = xhprof_disable();
@peterlozano
peterlozano / Readme.md
Last active August 29, 2015 13:57
ipv6 entries in /etc/hosts for MAMP
@peterlozano
peterlozano / .bashrc
Created March 19, 2014 09:49
Auto aliases to go to project directories. Place in .bashrc or .profile
for i in /var/www/*; do
if [ -d "$i/dev/www/sites/default" ]; then
alias `basename $i`="cd $i/dev/www/sites/default"
fi
done
@peterlozano
peterlozano / index.html
Last active August 29, 2015 14:02
Drupalcon Austin Videos
<html>
<head>
<meta charset="UTF-8">
<title>DC Austin Videos</title>
<script src="//underscorejs.org/underscore-min.js"></script>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<script id="tmpl-videos" type="text/template">
@peterlozano
peterlozano / Readme.md
Last active August 29, 2015 14:02
Global apache security file

This should be placed in /etc/apache2/conf.d and will provide global robot exclusion for all sites in the server.

The /var/www/robots.txt content is provided.

@peterlozano
peterlozano / index.html
Created June 25, 2014 09:28 — forked from anonymous/index.html
Test Map created wuth Odyssey.js
<!doctype><html><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Odyssey.js Slides</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="http://cartodb.github.io/odyssey.js/editor/favicon.png">
<link rel="icon" type="image/png" href="http://cartodb.github.io/odyssey.js/editor/favicon.png">
@peterlozano
peterlozano / gist:a4e9b7947953958a6964
Created July 3, 2014 09:21
PHP: Convert dates between timezones, independent of php timezone configuration.
<?php
$from_value = '2011-10-04 00:00:00';
// Create a date using the original timezone.
$from_timezone = 'America/New_York';
$date = new DateTime($from_value, new DateTimeZone($from_timezone));
// Move the date to another timezone.
$to_timezone = 'UTC';
@peterlozano
peterlozano / README.md
Last active August 29, 2015 14:03
Learning d3js.

Learning d3js

This is just a file that I used for learning basic d3.js and to use bl.ocks.org.

@peterlozano
peterlozano / README.md
Last active August 29, 2015 14:04
Cycloid Optical Illusion.