All posts by PF

Hack – programming language for HHVM – seamlessly PHP

Today we’re releasing Hack, a programming language we developed for HHVM that interoperates seamlessly with PHP. Hack reconciles the fast development cycle of PHP with the discipline provided by static typing, while adding many features commonly found in other modern programming languages.

We have deployed Hack at Facebook and it has been a great success. Over the last year, we have migrated nearly our entire PHP codebase to Hack, thanks to both organic adoption and a number of homegrown refactoring tools.

We’re also proud to release an open source version of Hack to the public http://www.hacklang.org/ as part of our HHVM runtime platform, which will now support both Hack and PHP.

 

 

WordPress caching – Quick Cache

I have a bunch of wordpress blogs, two of them getting 1k unique visitor each.

Both of homepage was taking almost 3 seconds to be compiled…
I’v installed a small WordPress Plugin named Quick Cache, to make cache of pages, and from almost 3 seconds now they are served in less that half of a second.

Before Quick Cache plugin

After Quick Cache plugin

History from some tests on the 10th of March and 17th of March.

CSS3 – change image – blur, brightness, saturation, hue, contrast, invert colors, grayscale and sepia

So, if you plan to change some of image properties with CSS filter is your solution.

-webkit-filter: filter(value);
-moz-filter: filter(value);
-o-filter: filter(value);
-ms-filter: filter(value);

You can replace filter with the following values

  • blur
  • brightness
  • saturate,
  • hue-rotate
  • contrast
  • invert
  • grayscale
  • sepia

Example

filter: invert(100%);
// Browser Specific
-webkit-filter: invert(100%);
-moz-filter: invert(100%);
-o-filter: invert(100%);
-ms-filter: invert(100%);

Concat/concatenate then

filter: blur(5px) brightness(0.5);

 

More readings

http://codepen.io/rss/pen/ftnDd
http://www.inserthtml.com/2012/06/css-filters/

Top 5 security flaws within websites and how to prevent them

So we’re now into 2014 and websites are starting to become way more advanced by implementing new technologies such as AJAX, fancy web forms and even web sockets. However, little do webmaster’s realise that they’re opening a space for huge security flaws within their websites / web applications / web services for malicious hackers to take advantage of.

Read more at http://joel-murphy.com/top-5-security-flaws-within-websites-and-how-to-prevent-them/

 

Fatal error: Class ‘DOMDocument’ not found

I was moving a WP from a host to another, and using the WordPress Importer while loading the XML of the export “Fatal error: Class ‘DOMDocument’ not found“.

We have two solutions

  • Install the php-xml package on your server.
  • Replace in file parsers.php in plugin wordpress-importer at class WXR_Parser_SimpleXML

Replace in file parsers.php in plugin wordpress-importer at Class WXR_Parser_SimpleXML

Change

$dom = new DOMDocument;
$old_value = null;
if ( function_exists( 'libxml_disable_entity_loader' ) ) {
$old_value = libxml_disable_entity_loader( true );
}
$success = $dom->loadXML( file_get_contents( $file ) );
if ( ! is_null( $old_value ) ) {
libxml_disable_entity_loader( $old_value );
}if ( ! $success || isset( $dom->doctype ) ) {
return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() );
}$xml = simplexml_import_dom( $dom );
unset( $dom );

For:

$xml = simplexml_load_file($file);

Displaying charts in tabs

I have two amcharts on different tabs. A stock chart to be place on #chartdiv and a pie chart to be placed on #chartdivpie. This is how I solved my problem.

My custom css – to overwrite bootstrap –

#chartdivpie { width: 1138px; height: 500px; }
.tab-content .tab-pane {
   position: absolute;
   top: -9999px;
   left: -9999px;
   display: inline;
}
.tab-content .tab-pane.active {
    position: inherit !important;
}

JQuery call

$('#myTab a').click(function (e) {
      e.preventDefault()
        $(this).tab('show');
        chart.invalidateSize();
        chart.write('chartdiv');
    })

 

See the discussion here http://stackoverflow.com/questions/10013408/amcharts-doesnt-display-chart-for-initially-hidden-divs/22289182#22289182