Skip to content

Instantly share code, notes, and snippets.

View cyrilf's full-sized avatar
🌱
what's up!

cyril cyrilf

🌱
what's up!
View GitHub Profile
@cyrilf
cyrilf / getNumber.js
Created December 21, 2012 22:05
A little improvement of parseFloat function to handle string in ending with %.
var f = getNumber('23.7'); // f = 23.7
//var f = getNumber(23.7); // f = 23.7
//var f = getNumber('23.7 px'); // f = 23.7
//var f = getNumber('23.7 %'); // f = 0.237
function getNumber(input) {
if( typeof input === 'string' && input.slice(-1) === '%') {
input = parseFloat(input.slice(0,-1))/100;
} else {
input = parseFloat(input);
@cyrilf
cyrilf / rmTopFrame.js
Created December 20, 2012 22:02
Remove Google Images Frame on your site and close it.
if (top.location != self.location)
top.location = self.location;
@cyrilf
cyrilf / includedByState-example.js
Last active August 29, 2015 14:14
includedByState filter improvement
// Improvement proposal
$IncludedByStateFilter.$inject = ['$state'];
function $IncludedByStateFilter($state) {
var includesFilter = function (state, params, options) {
return $state.includes(state, params, options);
};
includesFilter.$stateful = true;
return includesFilter;
}