BonBon Buttons

These are way above and beyond the level of any other “CSS3 buttons” I’ve seen. Multiple backgrounds combining gradients and images, uneven border-radius, pseudo elements, HSL coloring, @font-face icons, transitions, box shadows, text shadows, hover and active states… the list goes on. Every trick in the book masterfully employed.They make my buttons …

Post original

Share Button

Añadir estilos y scripts a la administración de plugins en WordPress

Cuando estamos desarrollando un plugin para WordPress y queremos que la administración del plugin tenga estilos y scripts propios, ya sea para darle cierta interactividad o diseño, o bien podremos incluir los estilos o librerías a pelo en la página del plugin, o bien podremos hacer que WordPress añada lo estilos y los scripts en el head del HTML. Para realizar esto, deberemos utilizar las acciones admin_print_styles y admin_print_scripts:

add_action('admin_print_styles', 'incluir_css');
add_action('admin_print_scripts', 'incluir_script');
 
function incluir_css() {
  echo '<link rel="stylesheet" href="'.get_bloginfo('wpurl').'/wp-content/plugins/miplugin/css/estilo.css" />';
}
 
function incluir_script() {
  echo '<script type="text/javacript" src="'.get_bloginfo('wpurl').'/wp-content/plugins/miplugin/js/script.js" ></script>';
}

Así de sencillo.

Share Button

Scale-out vs Scale-up

In this post I'll cover the difference between multi-core concurrency that is often referred to as Scale-Up and distributed computing that is often referred to as Scale-Out mode.  more.. Source: Scale-out vs Scale-up (http://www.dzone.com/links/r/scaleout_vs_scaleup.html) by Nati Shalom …

Post original

Share Button

PHPBuilder.com: Downloading and Parsing Gmail Messages in PHP

New on PHPBuilder.com today there’s a tutorial showing you how to download and parse messages from Google Mail. In their case it’s grabbing and parsing submissions from a form. Some friends of mine publish a literary journal that accepts submissions via email. At their request I wrote a script to download messages from the journal’s Gmail account a …

Post original

Share Button

NoSQL databases: 10 Things you Should Know About Them

NoSQL databases: 10 Things you Should Know About Them: 5 pros and 5 cons by Guy Harrison: Five advantages of NoSQL Elastic scaling Big data Goodbye DBAs (see you later?) Economics Flexible data models Five challenges of NoSQL Maturity Support Analytics and business intelligence Administration Expertise A few amendments though: Elastic scaling: part …

Post original

Share Button

Usar Solr desde PHP

Solr es un servidor de búsquedas basado en Lucene que nos puede venir muy bien cuando nuestro proyecto web necesite un motor de búsqueda en condiciones, siendo una alternativa a Sphinx. Aunque está basado en Java, existe una librería que permite trabajar con ella, otra posibilidad sería utilizar Zend Search, ya que usa el formato de Lucene, aunque en una versión anterior a la que utiliza Solr, por lo que nos encontramos con incompatibilidades.

El uso de la librería es bastante sencillo:

  require_once( 'Apache/Solr/Service.php' );
  
  // 
  // 
  // Try to connect to the named server, port, and url
  // 
  $solr = new Apache_Solr_Service( 'localhost', '8983', '/solr' );
  
  if ( ! $solr->ping() ) {
    echo 'Solr service not responding.';
    exit;
  }
  
  //
  //
  // Create two documents to represent two auto parts.
  // In practice, documents would likely be assembled from a 
  //   database query. 
  //
  $parts = array(
    'spark_plug' => array(
      'partno' => 1,
      'name' => 'Spark plug',
      'model' => array( 'Boxster', '924' ),
      'year' => array( 1999, 2000 ),
      'price' => 25.00,
      'inStock' => true,
    ),
    'windshield' => array(
      'partno' => 2,
      'name' => 'Windshield',
      'model' => '911',
      'year' => array( 1999, 2000 ),
      'price' => 15.00,
      'inStock' => false,
    )
  );
    
  $documents = array();
  
  foreach ( $parts as $item => $fields ) {
    $part = new Apache_Solr_Document();
    
    foreach ( $fields as $key => $value ) {
      if ( is_array( $value ) ) {
        foreach ( $value as $datum ) {
          $part->setMultiValue( $key, $datum );
        }
      }
      else {
        $part->$key = $value;
      }
    }
    
    $documents[] = $part;
  }
    
  //
  //
  // Load the documents into the index
  // 
  try {
    $solr->addDocuments( $documents );
    $solr->commit();
    $solr->optimize();
  }
  catch ( Exception $e ) {
    echo $e->getMessage();
  }
  
  //
  // 
  // Run some queries. Provide the raw path, a starting offset
  //   for result documents, and the maximum number of result
  //   documents to return. You can also use a fourth parameter
  //   to control how results are sorted and highlighted, 
  //   among other options.
  //
  $offset = 0;
  $limit = 10;
  
  $queries = array(
    'partno: 1 OR partno: 2',
    'model: Boxster',
    'name: plug'
  );
 
  foreach ( $queries as $query ) {
    $response = $solr->search( $query, $offset, $limit );
    
    if ( $response->getHttpStatus() == 200 ) { 
      // print_r( $response->getRawResponse() );
      
      if ( $response->response->numFound > 0 ) {
        echo "$query <br />";
 
        foreach ( $response->response->docs as $doc ) { 
          echo "$doc->partno $doc->name <br />";
        }
        
        echo '<br />';
      }
    }
    else {
      echo $response->getHttpStatusMessage();
    }
  }

También recomiendo que en el esquema de Solr añadamos el filtro de caracteres mapping-ISOLatin1Accent.txt, para que no tengamos problemas a la hora de buscar palabras acentuadas sin usar los acentos (cancion => canción).

Solr PHP Client

Share Button

Manipulate Colors in All Imaginable Combinations with xColor

The xcolor plugin is an easy-to-use jQuery extension to manipulate colors in all imaginable combinations. This plugin implements an extensiv color parser and a featureful set of color-manipulation methods. There is also an animate() extension to smooth CSS colors.Another useful method isReadable() completes the whole, by allowing you to check if a …

Post original

Share Button

NoSQL Guide for Beginners

NoSQL Guide for Beginners: Alexandre Porcelli has a great post for NoSQL beginners: one of the most frequent question that people use to ask me about nosql is: what is the best nosql tool that enables me start with using my programming language (java, .net, php, python, etc..)? its almost impossible to have a quick answer ‘cos it involves many thin …

Post original

Share Button

InfiniteGraph Use Case: Modeling Stackoverflow

InfiniteGraph Use Case: Modeling Stackoverflow: I didn’t hear much about InfiniteGraph after its 1.0 release, except this post that uses Stackoverflow data as input to demo some features of graph databases: The vertices in the graph are represented as the Users, Questions and Answers above while the edges are represented as the interactions between …

Post original

Share Button