|

Nueva AWS SDK for PHP

La gente de Amazon ha sacado una nueva SDK PHP para AWS que puede ser usada para acceder a los servicios que ofrece: Amazon Elastic Compute Cloud (EC2), the Amazon Simple Storage Service (S3), Amazon CloudFront, Amazon CloudWatch, Amazon SimpleDB, Amazon Simple Notification Service (SNS), Amazon Simple Queue Service (SQS) y Amazon Identify and Access Management (IAM).

Post original

Curiosa creación de objetos en PHP

Recuerda mucho a Javascript y frameworks tipo jQuery, para ello utiliza métodos encadenados y un objeto genérico:


// Define a new class
$animal = $class->new()
  ->def('init', function($t, $name) {
    $t->name = $name;
  })
  ->def('speak', function($t) {
    echo "My name is $t->name\n";
  });

// Extend a class
$dog = $animal->extend()
  ->def('speak', function($t) {
    echo "My name is $t->name, I have just met you and I love you, SQUIRREL!\n";
  })
  ->def('bark', function($t) {
    echo "Woof!\n";
  });

Para poder realizar esto se necesita crear la clase Obj:

class Obj {
  public function __construct($methods=array()) {
    $this->methods = $methods;
  }

  public function method($name) {
    if (!isset($this->methods[$name]))
      throw new BadMethodCallException();
    return $this->methods[$name];
  }

  public function fn($name, $fn) {
    $this->methods[$name] = $fn;
    return $this;
  }

  public function __call($name, $args) {
    return call_user_func_array(
      $this->method($name),
      array_merge(array($this), $args)
    );
  }
}

// Allow chaining method calls off the constructor..
function Obj($methods=array())
{
return new Obj($methods);
}

PHP Object Oriented Programming Reinvented

Vía / PHPDeveloper.org

Carga asíncrona de scripts en Webkit

Webkit está implementando en la última versión la carga de scripts de forma asíncrona, para ello hace uso de los atributos async y defer. Esta carga de scripts se realiza sin detener el renderizado del HTML y añade el evento onLoad para ejecutar un método cuando acabe de cargarse:


La diferencia entre async y defer es que async se ejecuta a la primera oportunidad después de que finalice la carga y antes de que se ejecute el evento load del objeto window, por lo que con bastante posibilidad el script se ejecute asíncronamente y no en el orden en el que se muestra en al página. Los scripts defer se ejecutarán en el orden en el que se indica en la página, pero empezará despues del parseo completo pero antes de que ocurra el evento DOMContentLoaded del objeto document.

Running scripts in WebKit

Vía / CSS-Tricks

Obtener URLs para usuarios en Codeigniter

Codeigniter tiene una método para tratar con las URLs: http://dominio/controlador/metodo/param1/param2/… El problema viene cuando nuestra aplicación necesita URLs diferentes, como las de Twitter u otra red social, que son del tipo http://dominio/username.

Para ello primero se debe cambiar el archivo routes.php de la configuración:

//Excluir estos controladores cuando se generan las URLs
$route['(login|oauth|site|search)(.*)'] = '$1$2';  
 
//Las URLs de los usuarios
$route['[a-zA-Z0-9]+/(add|edit)'] = 'users/$1';
$route['[a-zA-Z0-9]+'] = 'users/profile';

Después habrá que modificar el .htaccess para usar APP_PATH:

RewriteEngine On
 
RewriteBase /
 
RewriteCond %{ENV:REDIRECT_APP_PATH} !^$
RewriteRule ^(.*)$ - [E=APP_PATH:%{ENV:REDIRECT_APP_PATH}]
 
RewriteCond %{ENV:APP_PATH} ^$
RewriteRule ^(.*)$ - [E=APP_PATH:/$1]
 
RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]

Y por último modificar el config.php para indicar que debe usar el APP_PATH:

$config['uri_protocol']    = "APP_PATH";
 
$config['enable_query_strings'] = TRUE;

Codeigniter Vanity URLs

Vía / PHPDeveloper.org

|

HTML5′s “email” and “url” Input Types

I’ve already covered some subtle HTML5 improvements like placeholder, prefetching, and web storage.  Today I want to introduce a few new INPUT element types:  email and url.  Let’s take a very basic look at these new INPUT types and discuss their advantages.The SyntaxThe syntax is as basic as a text input;  instead, you set the type to “email” or “ …

Post original

|

Transparent Borders with background-clip

Have you ever seen an element on a page with transparent borders? I think Facebook originally popularized it giving birth to lightbox plugins like Facebox. I don’t think Facebook sports the look anymore, but it’s still rather neat. You might think it would be as simple as this:#lightbox { background: white; border: 20px solid rgba(0,0,0,0.3); }Howe …

Post original

|

Neo4j Gets Geo Support

I guess that’s what kept the Neo Technology — the guys behind Neo4j — busy lately: The Neo4j Spatial project supports the use of geographic data by providing utilities that simplify and support advanced capabilities like: Storage of geographic features like points, lines and polygons as graphs Indexing and querying based on location with R-trees, Q …

Post original