Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
SHADOW_FILE="/etc/shadow"
DATE=$(( $(date -u '+%s') / 60 / 60 / 24 ))
REPLACEMENT=$(echo "account-$1:$2:$DATE:0:99999:7:::" | sed -e 's/\(\/\|\\\|&\)/\\&/g')
sed -i "s/^account-$1:.*$/$REPLACEMENT/" $SHADOW_FILE \
&& echo "success"
class TrackingMiddleware
attr_accessor :app
def initialize(app)
self.app = app
end
def call(env)
if env["PATH_INFO"] == '/tracker'
req = Rack::Request.new(env)
p = req.params.select{|k,v| TrackingWorker::FIELDS.has_key?(k) }
@mrkurt
mrkurt / map.coffee
Created August 20, 2011 06:04
Testing Mongo map/reduce functions in isolation
map = ()->
return unless @a? #skip things with no actions array
return unless @i?
time = @_id.getTimestamp().getTime()
hour = time / 1000 / 3600
cst = hour - 6
key = parseInt(cst / 24).toString() + "-" + hex_md5(@i.join('-'))
val = {actions : {}, ids : @i, time : time}
for a in @a
val.actions[a] = 1
@mrkurt
mrkurt / Gemfile
Created August 21, 2011 19:10
The magical document eating has_many assignment
source :rubygems
gem 'mongoid'
mongodb = require('mongodb');
url = "mongodb://username@password:host1:27017,host2:27017,host3:27017/database";
mongodb.connect(url, function(err, database){
if(err){
console.log("Could not connect: " + err);
}else{
console.log("Connected to repl set: " + database.serverConfig.replicaSet);
}
});
class Sparkline
constructor : (elem, @data, @opts)->
@opts ||= {}
_.extend(@opts, Sparkline.defaults)
@width = $(elem).width()
@height = $(elem).height()
@graph = d3.select(elem).append("svg:svg").attr("width", @width).attr("height", @height)
@data ||= [0]
@setScale()
@mrkurt
mrkurt / retry.rb
Created March 30, 2012 20:26 — forked from bhbryant/retry.rb
auto-failover ReplicaSet config for MongoMapper, by way of ruby driver
replica_sets = mm_env['replica_sets'] # node1:port&node2:port
rs_list = replica_sets.split("&").map {|rs| host,port = rs.split(":"); [host,port.to_i] }
MongoMapper.connection = Mongo::RetryReplicaSetConnection.new(*(rs_list << {:read_secondary => true, :auto_refresh => true }))
MongoMapper.database = mm_env['database']
MongoMapper.database.authenticate(mm_env['username'], mm_env['password'])
<h3>Hours Worked</h3>
<% user_signed_in? %>
<table>
<table class="table table-striped table-bordered table-condensed table-hover">
<thead>
<thead>
<tr>
<th>Date</th>
<th>Hours Worked</th>
<th>Start</th>
### Keybase proof
I hereby claim:
* I am mrkurt on github.
* I am mrkurt (https://keybase.io/mrkurt) on keybase.
* I have a public key whose fingerprint is 4242 13F4 A4D3 58EB 4DFA 015D 26F1 07C0 D8CD 17A1
To claim this, I am signing this object:
@mrkurt
mrkurt / who's-hiring-may-2018.md
Last active May 4, 2018 01:28
Who's hiring? Fly is!

fly.io | Writer / Dev Advocate | Chicago or Remote | Full Time

fly.io is an open core, programmable CDN. Developers write JavaScript Edge Applications locally, test them, and deploy across our global network of servers.

We're hiring to improve our publishing! You might want to apply if you enjoy JavaScript and writing for developers. You'll be really good for this role if you can come up with interesting ideas and turn them into finished content. We're remote first, and super flexible, so you hopefully like talking to other people on Slack and getting together with the rest of the company every few months. If you like giving talks and going to conferences, you can do that too (but it's not a requirement)!

Example content: