Skip to content

Instantly share code, notes, and snippets.

@mrkurt
mrkurt / ip-valuations.rb
Created February 16, 2021 18:35
Cloud provider IP valuations
require "ipaddr"
require "net/http"
require "uri"
require "json"
def fetch(uri_str, limit = 10)
# You should choose better exception.
raise ArgumentError, "HTTP redirect too deep" if limit == 0
url = URI.parse(uri_str)
dist
lib
build
node_modules
.nyc_output
bin/fly
.fly
package-lock.json
yarn.lock
@mrkurt
mrkurt / regex.js
Last active October 10, 2018 15:59
Kurt
import proxy from "@fly/proxy"
import { forceSSL } from './lib/utilities'
const origin = proxy("https://viaglamour.com/")
/**
* Rewrite the path to /store/<hostname>
*/
function rewriteRequest(req) {
const url = new URL(req.url)
let path = "/store/" + url.hostname.replace(/\.[a-z]+/, '')
@mrkurt
mrkurt / fly-aws-sdk.js
Created July 13, 2018 18:48
Using the AWS SDK in a Fly App
import * as AWS from 'aws-sdk'
AWS.HttpClient.prototype.handleRequest = function handleRequest(httpRequest, httpOptions, callback, errCallback) {
var self = this;
var endpoint = httpRequest.endpoint;
var emitter = new EventEmitter();
callback(emitter);
var href = endpoint.protocol + '//' + endpoint.hostname;
if (endpoint.port !== 80 && endpoint.port !== 443) {
@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:

### 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:
<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>
@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'])
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()
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);
}
});