Skip to content

Instantly share code, notes, and snippets.

View neojp's full-sized avatar

Joan P. neojp

View GitHub Profile
@neojp
neojp / gist:1865776
Created February 19, 2012 21:06
Slugify a string, remove whitespace, convert accented letters and some signs
slugify = (str) ->
str = str.replace /^\s+|\s+$/g, ''
str = str.toLowerCase()
# remove accents, swap ñ for n, etc
from = "àáäâèéëêìíïîòóöôùúüûñ箩·/_,:;"
to = "aaaaeeeeiiiioooouuuuncrc------"
for i, character of from.split ''
str = str.replace new RegExp(character, 'g'), to.charAt i
@neojp
neojp / Node.js: Using "supervisor" with "Locomotive"
Created February 16, 2012 19:59
Runs a Locomotive app, listens and auto-reloads server if code changes are found.
# node-supervisor: https://github.com/isaacs/node-supervisor
# locomotive: http://locomotivejs.org/
supervisor --watch app/controllers,config,config/environments,config/initializers -- node_modules/locomotive/bin/lcm.js server