Skip to content

Instantly share code, notes, and snippets.

View aeden's full-sized avatar

Anthony Eden aeden

View GitHub Profile
@aeden
aeden / test.rb
Created July 7, 2011 08:53
Temporarily Overriding A Method in Ruby
module Count
def fake_count
words.count + 500
end
end
class Thing
def words
%w(one two three)
end
#!/usr/bin/env ruby
require 'dnsimple'
# Construct a client instance.
#
# If you want to connect to production, omit the `base_url` option.
#
# Note that in this case a bogus access token is being sent to show what happens when authentication
# fails.
client = Dnsimple::Client.new(base_url: "https://api.sandbox.dnsimple.com", access_token: "fake")
Verifying that +aeden is my blockchain ID. https://onename.com/aeden
@aeden
aeden / const2fun.rb
Last active May 16, 2016 06:58
Ruby script to convert erlang define to functions, for access from Elixir
#!/usr/bin/env ruby
# Converts all Erlang macro defines to Erlang functions.
# This is useful if you want to access those values from Elixir.
#
# If the defines are in an .hrl file, you should copy all of the
# defines into a .erl file first and then run the script on that
# .erl file. The script will copy the .erl file to .erl.old and
# then will overwrite the existing .erl file.

DNS records get cached, as we have seen above. So if your DNS record is cached for IP address 1.2.3.4 and the service provider changes the record to 5.6.7.8, you will send traffic for your mapped apex domain to the wrong address until the record expires in all caching resolvers.

This is true for any cached request, not just an ALIAS. As a matter of fact, the way we implement the ALIAS record is to always attempt the lookup through an upstream caching resolver, so we are effectively behaving the same way a client sending the request directly to the caching resolver would.

You also potentially break geoIP optimisations because suddenly you request the IP address from the nameserver of your DNS provider, not from your actual location. This may even get you in trouble with location restricted services (think Unblock-Us, just not in an intended way).

With Anycast the results of geocaching can potentially be mitigated because the request will be resolved at an Anycast server near the client. As you add more

@aeden
aeden / podcasts.txt
Created May 28, 2013 11:56
Podcast Playlist
Morgan Page - In The Air
Arty - Together We Are
Corsten's Countdown
The Gareth Emery Podcast
Hardwell On Air
Tiesto's Club Life
Above & Beyond - Group Therapy

The limiting factor of erl-dns QPS is in the loop around reading a UDP packet and getting it to a worker, as this is currently executed in a synchronous loop. Workers are asynchronous, so once they have the packet the next UDP packet can be read.

Reading a packet in Erlang is reported to take 10s of microseconds. Casting the packet to the worker takes about 100 microseconds. Getting a worker out of the worker queue is currently the slowest part of the process, taking around 1 millisecond. Originally I was using Poolboy, however pulling workers off the queue was taking 4 to 6 milliseconds.

The approach I am testing now is to have multiple processes reading from the same UDP socket. Under no inbound traffic this strategy does not work too well because there are a lot of ealready errors since the socket is blocking. My current theory is that under high traffic loads these will go away since there will be a constant stream of requests, however it's possible that the number of workers listening to the socket wil

$ erl
Erlang R15B (erts-5.9) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9 (abort with ^G)
1> c(example1).
{ok,example1}
2> example1:sum(10, 20).
30
@aeden
aeden / txt-data-parser.erl
Created November 30, 2012 18:18
A TXT data lexer in Erlang
parse_txt([C|Rest]) -> parse_txt_char([C|Rest], C, Rest, [], false).
parse_txt(String, [], [], _) -> [String];
parse_txt(_, [], Tokens, _) -> Tokens;
parse_txt(String, [C|Rest], Tokens, Escaped) -> parse_txt_char(String, C, Rest, Tokens, Escaped).
parse_txt(String, [C|Rest], Tokens, CurrentToken, Escaped) -> parse_txt_char(String, C, Rest, Tokens, CurrentToken, Escaped).
parse_txt_char(String, $", Rest, Tokens, _) -> parse_txt(String, Rest, Tokens, [], false);
parse_txt_char(String, _, Rest, Tokens, _) -> parse_txt(String, Rest, Tokens, false).
parse_txt_char(String, $", Rest, Tokens, CurrentToken, false) -> parse_txt(String, Rest, Tokens ++ [CurrentToken], false);
parse_txt_char(String, $", Rest, Tokens, CurrentToken, true) -> parse_txt(String, Rest, Tokens, CurrentToken ++ [$"], false);
parse_txt_char(String, $\\, Rest, Tokens, CurrentToken, false) -> parse_txt(String, Rest, Tokens, CurrentToken, true);