Skip to content

Instantly share code, notes, and snippets.

@paulmillr
paulmillr / Gruntfile.js
Created September 11, 2012 10:11
yeoman default config
module.exports = function( grunt ) {
'use strict';
//
// Grunt configuration:
//
// https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
//
grunt.initConfig({
// Project configuration
@paulmillr
paulmillr / grunt.js
Last active April 26, 2016 14:31
Gulp / grunt
module.exports = function ( grunt ) {
/**
* Load required Grunt tasks. These are installed based on the versions listed
* in `package.json` when you do `npm install` in this directory.
*/
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
routes = require './routes'
# Execute handler on document ready event.
jQuery ->
# Initialise new Chaplin application.
# Specify controller suffix for clarity.
new Chaplin.Application
controllerSuffix: '-controller', pushState: false, routes: routes
@paulmillr
paulmillr / replace-to-dashes.coffee
Created June 9, 2012 14:33
Add dashes to CoffeeScript source. toString ⇒ to-string. Issue #2370
fs = require 'fs'
# Usage: coffee replace-to-dashes.coffee src/**/*
replaceFile = (path) ->
fs.readFile path, (error, data) ->
return console.log error if error?
result = data
.toString()
.replace /([a-z])([A-Z])([a-z])/g, ($0, $1, $2, $3) ->
@paulmillr
paulmillr / mapreduce.scala
Created March 10, 2012 16:03
Why functional programming matters (aka MapReduce for humans)
import com.cloudera.crunch._
import com.cloudera.scrunch._
class ScrunchWordCount {
def wordCount(inputFile: String, outputFile: String) = {
val pipeline = new Pipeline[ScrunchWordCount]
pipeline.read(from.textFile(inputFile))
.flatMap(_.toLowerCase.split("\\W+"))
.filter(!_.isEmpty())
.count
@paulmillr
paulmillr / mongodb_sharding.sh
Created August 10, 2011 10:30
MongoDB sharding setup (quick & dirty)
#!/usr/bin/env zsh
# Change "Mongal" in text to name of your collection.
DATADIR="$HOME/Documents/data"
mkdir -p $DATADIR/db/{config,logs,0,1,2,3}
mkdir $DATADIR/backup
cd $DATADIR/db/logs
touch 0.log 1.log 2.log 3.log config.log main.log
chmod 666 *.log