Skip to content

Instantly share code, notes, and snippets.

View pavelthq's full-sized avatar

Pavel pavelthq

View GitHub Profile
@aguegu
aguegu / octocats.sh
Last active December 23, 2015 11:07
A bash script to download all Octocats logos from http://octodex.github.com/
#!/bin/zsh
curl -s "https://octodex.github.com/" | grep "<img.*data-src" | grep -o "/image[^\"]*" | while read line; do
wget 'https://octodex.github.com'$line
done
@timruffles
timruffles / chunk.js
Last active October 8, 2015 19:18
underscore chunk method
// Turns a list into a list of lists of specified lengths.
_.chunk = function(array,chunkSize) {
return _.reduce(array,function(reducer,item,index) {
reducer.current.push(item);
if(reducer.current.length === chunkSize || index + 1 === array.length) {
reducer.chunks.push(reducer.current);
reducer.current = [];
}
return reducer;
},{current:[],chunks: []}).chunks
@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
}