Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
_

Paul Miller paulmillr

:octocat:
_
View GitHub Profile
View __init__.py
import reclaimer
import uploader
# Example app code is mp7sh5jd6
@paulmillr
paulmillr / mongodb_sharding.sh
Created Aug 10, 2011
MongoDB sharding setup (quick & dirty)
View mongodb_sharding.sh
#!/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
@paulmillr
paulmillr / mapreduce.scala
Created Mar 10, 2012
Why functional programming matters (aka MapReduce for humans)
View mapreduce.scala
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 / replace-to-dashes.coffee
Created Jun 9, 2012
Add dashes to CoffeeScript source. toString ⇒ to-string. Issue #2370
View replace-to-dashes.coffee
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 / profiler.coffee
Created Jun 18, 2012
No-bullshit node.js profiler
View profiler.coffee
microtime = require 'microtime'
global.profiler = profiler =
profilings: Object.create(null)
current: Object.create(null)
start: (name) ->
profiler.profilings[name] ?= 0
profiler.current[name] = microtime.now()
@paulmillr
paulmillr / commonjs-test.js
Created Jun 20, 2012
Quick and dirty test for commonjs modules
View commonjs-test.js
var mocha = require('mocha');
var chai = require('chai');
var expect = chai.expect;
var window = {};
var w = window;
// Require definition.
@paulmillr
paulmillr / fp-ct.md
Created Jul 25, 2012
Functional programming terms described by category theory
View fp-ct.md
  • Monad is a monoid in the category of endofunctors.
  • Lens is exactly the Coalgebra for the CoState Comonad.
  • Iteratee is a standard stream fusion hylomorphism stuff with a left fold.
@paulmillr
paulmillr / vk-helpers.js
Last active Oct 9, 2015
VK.com JS / LiveScript helpers
View vk-helpers.js
var queryAll = function(selector) {
return [].slice.call(document.querySelectorAll(selector));
};
// 1. Open album.
// 2. Execute code in console.
// 3. Press → button until the end of the album
// 4. Then execute `printLinks();`, copy the output and pass it to wget.
var addAlbumPhotoLinks = function() {
var links = [];
@paulmillr
paulmillr / less2stylus.coffee
Created Oct 17, 2012 — forked from LabiKyo/less2stylus.coffee
Convert Less to Stylus for general purpose
View less2stylus.coffee
replacements = [
# Remove opening brackers.
[/^(\ *)(.+)\ +\{\ *\n?\ */mg, '$1$2\n$1 '],
[/^(\ *)([^\ \n]+)\ +\{\ *\n?\ */mg, '$1$2\n$1 '],
[/\ *\{\ *\n*/g, '\n'],
# Remove closing brackets.
[/\ *\}\ *\n*/g, '\n'],
# Remove semicolons.
@paulmillr
paulmillr / safari-web-inspector.md
Last active Oct 12, 2015
Safari web inspector evolution
View safari-web-inspector.md

As a developer, i’m curious what happens to tools I use. Some time ago I decided to log all changes in web inspectors of browsers.

So far list includes only Safari and Firefox primarly because it’s easy to track their changes. In the future other browsers will be in too.

Safari web inspector evolution

  • August 2012: Initial release of new safari web inspector. It had terrible UI / UX.
  • October:
    • Reduced main panels count from 8 to 3-4.
  • November:
You can’t perform that action at this time.