Showing latest posts from "code"

Top Facebook Twitter Comments

HexGL's source code is now on GitHub!

Yup, you read it right, HexGL's source code is now available on GitHub.

Go check the code out on HexGL's GitHub page, and feel free to submit suggestions, patches or issues!

Read more
Top Facebook Twitter Comments

A quick Performance.now() polyfill

(function(w){
	var perfNow;
	var perfNowNames = ['now', 'webkitNow', 'msNow', 'mozNow'];
	if(!!w['performance']) for(var i = 0; i < perfNowNames.length; ++i)
	{
		var n = perfNowNames[i];
		if(!!w['performance'][n])
		{
			perfNow = function(){return w['performance'][n]()};
			break;
		}
	}
	if(!perfNow)
	{
		perfNow = Date.now;
	}
	w.perfNow = perfNow;
})(window);

// Usage
console.log(window.perfNow());

Just a quick performance.now() polyfill since the ones I found were producing "Illegal invocation" errors. This polyfill wraps the performance call inside a function to avoid this.

Performance.now() polyfill on GIST

Read more
Top Facebook Twitter Comments

(PHP) NoCSRF, a simple class to prevent CSRF attacks.

When building an application or a website using PHP, you should be concerned with security.

One of the most common attacks used by malicious hackers is the Cross-Site Request Forgery (CSRF). This simple anti-CSRF token generation/checking class written in PHP5 will protect your form handlers from being hijacked to run unexpected actions.

Read more
Top Facebook Twitter Comments

(PHP) Late static binding and child attribute declaration

Late static binding is one of the most useful feature brought to us by the PHP team on version 5.3. It enables access of child static variables from parent classes.

Understanding the exact behaviour of this feature is crucial when dealing with static class inheritance.

Read more
Top Facebook Twitter Comments

(JS) Scroll animation with custom jScrollPane plugin

jScrollPane is a jQuery plugin written by Kelvin Luck that "converts a browser's default scrollbars into an HTML structure which can be easily skinned with CSS". It is a great peace of code I had the opportunity to work on during my recent projects, but it still lacks a bit of fanciness, particularly on scrolling animations.

This is why I came up with this custom version of the plugin, adding support for mousewheel and keyboard scroll animations.

Read more
Top Facebook Twitter Comments

(CSS) Prevent @font-face variants render issue

/* CSS Document */
@font-face
{
    font-family: comfortaa;
    src: url('comfortaa.eot');
    src: local(comfortaa), url('comfortaa.ttf') format('opentype');
}

While @font-face custom fonts on websites is an accessible alternative to Cufon, some web browsers tend to render font variants differently. This can sometimes be quite painful for the standard UI/UX designer.

Read more
End of items timeline.