This file contains 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
import urllib2 | |
class RoboWhois: | |
def __init__(self, api_key): | |
self.username = api_key | |
self.password = "X" | |
def whois(self, domain): | |
template = "http://api.robowhois.com/whois/%s" |
This file contains 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
import urllib2 | |
def whois(domain): | |
api_key = "YOUR_API_KEY" | |
template = "http://api.robowhois.com/whois/%s" | |
passman = urllib2.HTTPPasswordMgrWithDefaultRealm() | |
passman.add_password(None, "http://api.robowhois.com/", api_key, "X") | |
handler = urllib2.HTTPBasicAuthHandler(passman) | |
opener = urllib2.build_opener(handler) |
This file contains 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
<% | |
' Requests the parsed WHOIS record for the domain | |
' and returns a String containing the JSON-encoded parsed WHOIS properties. | |
Function WhoisProperties(url) | |
Dim objXmlHttp | |
Set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP") | |
objXmlHttp.Open "GET", url, False, "YOUR_API_KEY", "X" |
This file contains 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
<?php | |
/* Requests the parsed WHOIS record for the domain | |
* and returns an Array containing the parsed WHOIS properties. | |
* | |
* @param string $domain The domain to lookup. | |
* | |
* @return array | |
*/ | |
function whoisProperties($domain) |
This file contains 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
(function($){ | |
$.fn.ifdo = function(fn) { | |
if (this.length > 0) { | |
fn.call(this); | |
} | |
}; | |
})(jQuery); |
This file contains 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
$ cloc robodomain robowhois robofinance whois | |
1824 text files. | |
1695 unique files. | |
920 files ignored. | |
http://cloc.sourceforge.net v 1.51 T=2.0 s (433.5 files/s, 50222.5 lines/s) | |
------------------------------------------------------------------------------- | |
Language files blank comment code | |
------------------------------------------------------------------------------- | |
Ruby 747 12136 7589 41135 |
This file contains 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
MongoDb vs PostgreSQL (single table with 777,229 records) | |
-------------------------------------------------------- | |
# Number of Records in the table | |
=> 777229 | |
# Size of the Table | |
# PostgreSQL (Data + Indexes) | |
+----------------+ |
This file contains 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 CacheKey | |
extend self | |
def expirable(range = :minute, time = ::Time.current) | |
key = case range | |
when :always | |
::Time.current | |
when :never | |
nil | |
when :second |
This file contains 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
require 'rubygems' | |
require 'benchmark' | |
require 'nokogiri' | |
TIMES = 50_000 | |
doc = Nokogiri::XML(File.new("test.xml")) | |
node = doc.at_xpath("./strategies") | |
Benchmark.bmbm do |x| |
This file contains 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
require 'ipaddr' | |
require 'benchmark' | |
class IPAddr | |
def self.valid_ipv4?(addr) | |
if /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\Z/ =~ addr | |
return $~.captures.all? {|i| i.to_i < 256} | |
end | |
false | |
end |