Skip to content

Instantly share code, notes, and snippets.

:octocat:
_

Paul Miller paulmillr

:octocat:
_
Block or report user

Report or block paulmillr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 / dart.md
Last active Apr 24, 2020
Leaked internal google dart email
View dart.md

---------- Forwarded message ----------

From: Mark S. Miller <erights@google.com>
Date: Tue, Nov 16, 2010 at 3:44 PM
Subject: "Future of Javascript" doc from our internal "JavaScript Summit"
last week
To: javascript-standard@google.com
@paulmillr
paulmillr / unicode_transformer.py
Created Sep 24, 2011
A plugin for Sublime Text 2 that replaces some symbols with their unicode equivalents.
View unicode_transformer.py
# encoding: utf-8
import sublime
import sublime_plugin
class UnicodeTransformer(sublime_plugin.EventListener):
"""The transfrormer was tested with CoffeeScript code."""
_just_io = False # Determines if the file was just loaded / saved.
_is_saving = False
@paulmillr
paulmillr / method-missing.coffee
Created Jan 20, 2012
ECMAScript 6 proxies fun (method missing, negative array indexes)
View method-missing.coffee
# Ruby’s “method missing” analog with ES6 proxies.
proxify = (object) ->
new Proxy object, get: (receiver, name) ->
object[name] ? object.methodMissing.bind object, name
object = proxify
a: 1,
b: 15,
c: ->
'called'
@paulmillr
paulmillr / less.less
Created Mar 9, 2012
Sass vs Stylus vs LESS
View less.less
.border-radius (@radius) {
-webkit-border-radius: @radius;
-o-border-radius: @radius;
-moz-border-radius: @radius;
-ms-border-radius: @radius;
border-radius: @radius;
}
.user-list {
// need to use special `.` syntax
@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 / great_code.hs
Created May 4, 2012
Cool & pretty readable haskell code
View great_code.hs
data Cargo = Peasant
| Cabbage
| Wolf
| Goat
deriving (Eq, Enum, Show)
type ShoreState = [Cargo]
type Move = [Cargo]
type State = (ShoreState, ShoreState)
@paulmillr
paulmillr / active.md
Last active May 27, 2020
Most active GitHub users (by contributions). http://twitter.com/paulmillr
View active.md

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Tue, 06 Dec 2016 17:06:46 GMT till Wed, 06 Dec 2017 17:06:46 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
  .filter(user => user.followers > 1000)
@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()
You can’t perform that action at this time.