Skip to content

Instantly share code, notes, and snippets.

View ikluhsman's full-sized avatar
🤓
Feeling Nerdy

Ian Kluhsman ikluhsman

🤓
Feeling Nerdy
  • Self Employed
  • Denver, CO
View GitHub Profile
@joseluisq
joseluisq / slugify.js
Last active August 3, 2023 17:21 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify (text, ampersand = 'and') {
const a = 'àáäâèéëêìíïîòóöôùúüûñçßÿỳýœæŕśńṕẃǵǹḿǘẍźḧ'
const b = 'aaaaeeeeiiiioooouuuuncsyyyoarsnpwgnmuxzh'
const p = new RegExp(a.split('').join('|'), 'g')
return text.toString().toLowerCase()
.replace(/[\s_]+/g, '-') // Replace whitespace and underscore with single hyphen
.replace(p, c =>
b.charAt(a.indexOf(c))) // Replace special chars
.replace(/&/g, `-${ampersand}-`) // Replace ampersand with custom word
@vadviktor
vadviktor / move.py
Created August 30, 2012 14:28
Python: move files to creation date named directories
#!/usr/bin/python3
import os, time, shutil, sys
dir = sys.argv[1]
os.chdir(dir)
for f in os.listdir('.'):
ftime = time.gmtime(os.path.getmtime(f))
ctime_dir = str(ftime.tm_year) '-' str(ftime.tm_mon) '-' str(ftime.tm_mday)
if not os.path.isdir(ctime_dir):
os.mkdir(ctime_dir)