Skip to content

Instantly share code, notes, and snippets.

@lazureykis
lazureykis / collision.js
Created June 2, 2021 11:00 — forked from samcorcos/collision.js
Algorithm for calculating hash collision probability
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
@lazureykis
lazureykis / kill_rubies.sh
Created February 20, 2019 14:19 — forked from padi/kill_rubies.sh
Script to kill all spring and rogue ruby processes
#!/bin/sh
ps aux | grep ruby | grep -v grep | awk '{print $2}' | xargs kill
@lazureykis
lazureykis / logger_middleware.rb
Created July 25, 2018 07:23 — forked from skwp/logger_middleware.rb
A request/response logger Rack middleware.
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_'}
@lazureykis
lazureykis / di-fm-premium-account-generator.sh
Created October 14, 2016 21:25 — forked from hackruu/di-fm-premium-account-generator.sh
Generate di.fm premium account and playlist. Also supports radiotunes.com (ex sky.fm) and jazzradio.com.
#!/bin/bash
AGENT="AudioAddict-di/1.4.7 iOS/8.1"
COOKIES="./cookies.txt"
AUTH="ephemeron:dayeiph0ne@pp"
DOMAIN=gmail.com
PLAYLISTDI="di.fm.m3u"
PLAYLISTSKY="sky.fm.m3u"
PLAYLISTJAZZ="jazzradio.m3u"
PLAYLISTROCK="rockradio.m3u"
JSONDI="http://listen.di.fm/premium_high.json"
@lazureykis
lazureykis / Readme.md
Last active August 27, 2015 11:08 — forked from vodafon/Readme.md
Linking #GoLang lib in #Ruby
go build -buildmode=c-shared -o sum.so sum.go
ruby link.rb
@lazureykis
lazureykis / nginx.conf
Last active December 15, 2015 13:59 — forked from jtimberman/nginx.conf
# 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;