go build -buildmode=c-shared -o sum.so sum.go
ruby link.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const calculate = (n, k) => { | |
| const exponent = (-k * (k - 1)) / (2 * n) | |
| return 1 - Math.E ** exponent | |
| } | |
| // where `n` is the number of possible unique hashes | |
| // where `k` is the number of values created | |
| // calculate(100000, 25) => 0.0029955044966269995 aka 0.29% chance of collision |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| ps aux | grep ruby | grep -v grep | awk '{print $2}' | xargs kill |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Middleware | |
| class Logger | |
| def initialize(app, logger) | |
| @app = app | |
| @logger = logger | |
| end | |
| def call(env) | |
| headers = env.select {|k,v| k.start_with? 'HTTP_'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Config for Nginx to act as a front-end for Riak | |
| # The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc) | |
| # Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_) | |
| # Config is in /etc/nginx/sites-available/default or somewhere like that | |
| # Set up load-balancing to send requests to all nodes in the Riak cluster | |
| # Replace these IPs/ports with the locations of your Riak nodes | |
| upstream riak_hosts { | |
| server 127.0.0.1:8098; |