Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\З= ( ▀ ͜͞ʖ▀) =Ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿

Radu-Sebastian Amarie eek

🎯
̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\З= ( ▀ ͜͞ʖ▀) =Ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿
View GitHub Profile
@eek
eek / slugify.js
Last active Apr 30, 2018
Vanilla JavaScript Slugify + Accent removal - Just another JavaScript Slugifier with an extra line for Accent Removal
View slugify.js
function slugify(text) {
return text.toString().toLowerCase().trim()
.normalize('NFD') // separate accent from letter
.replace(/[\u0300-\u036f]/g, '') // remove all separated accents
.replace(/\s+/g, '-') // replace spaces with -
.replace(/&/g, '-and-') // replace & with 'and'
.replace(/[^\w\-]+/g, '') // remove all non-word chars
.replace(/\-\-+/g, '-') // replace multiple '-' with single '-'
}
@eek
eek / localStoragePollyfill.js
Last active Aug 9, 2017
localStorage Pollyfill for Safari / Chrome Private / Incognito Mode & Others
View localStoragePollyfill.js
try {
localStorage.setItem('test', true);
} catch (e) {
if (e.code == 22) { //localStorage exists but size limit -> Probably Safari Private Mode.
localStorage.__proto__ = Object.create(Storage.prototype);
localStorage.__proto__._data = {};
localStorage.__proto__.setItem = function (id, val) {
return this._data[id] = String(val)
};
localStorage.__proto__.getItem = function (id) {
You can’t perform that action at this time.