Skip to content

Instantly share code, notes, and snippets.

@bentruyman
bentruyman / slug.js
Created September 12, 2011 14:31
JavaScript Slug Generator
// Generates a URL-friendly "slug" from a provided string.
// For example: "This Is Great!!!" transforms into "this-is-great"
function generateSlug (value) {
// 1) convert to lowercase
// 2) remove dashes and pluses
// 3) replace spaces with dashes
// 4) remove everything but alphanumeric characters and dashes
return value.toLowerCase().replace(/-+/g, '').replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
};
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@utsengar
utsengar / gmail_analyze.py
Created May 24, 2012 07:55
Analyze gmail data
#Install scipy: http://glowingpython.blogspot.it/2012/05/analyzing-your-gmail-with-matplotlib.html
from imaplib import IMAP4_SSL
from datetime import date,timedelta,datetime
from time import mktime
from email.utils import parsedate
from pylab import plot_date,show,xticks,date2num
from pylab import figure,hist,num2date
from matplotlib.dates import DateFormatter
@sindresorhus
sindresorhus / blur-prank.user.js
Last active January 4, 2023 10:33
Blur prank UserScript
// ==UserScript==
// @name Dictionary
// @version 0.1
// @author Sindre Sorhus
// @include *
// ==/UserScript==
document.documentElement.style.webkitFilter='blur(0.5px)';
@r-sal
r-sal / PHPExcel_Basics.md
Last active May 8, 2024 06:29
PHPExcel Notes and code snippets

Basics

Creating a new PHPExcel Object.

    $this->PHPExcel = new PHPExcel();

Working with sheets

Creating a new sheet:

PHP Snippets

Switching between \n and

define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
echo date('H:i:s') , " Load from Excel5 template" , EOL;

@n1k0
n1k0 / casperjs-link-checker.md
Last active August 5, 2016 04:58
A link checker using CasperJS
@r-sal
r-sal / CSSSnippets.md
Last active December 11, 2015 05:19
Small collection of various code snippets

Display an HTML attribute value in CSS with attr()
To display the data-prefix attribute of an

heading

<h3 data-prefix="Custom prefix">This is a heading</h3>
h3:before {
  content: attr(data-prefix) " ";
}

@r-sal
r-sal / essentialUnixCommands.md
Last active December 13, 2015 18:09
Most Important UNIX commands