Skip to content

Instantly share code, notes, and snippets.

View weppos's full-sized avatar

Simone Carletti weppos

View GitHub Profile
@weppos
weppos / robowhois.py
Created June 7, 2012 18:30
RoboWhois + Python example: get the WHOIS record for a domain.
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"
@weppos
weppos / example.py
Created June 7, 2012 18:28
RoboWhois + Python example: get the WHOIS record for a domain.
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)
@weppos
weppos / whois-properties.asp
Created April 15, 2012 18:23
RoboWhois + ASP example: get the parsed WHOIS record for a domain.
<%
' 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"
@weppos
weppos / whois-properties.php
Created April 2, 2012 08:50
RoboWhois + PHP example: get the parsed WHOIS record for a domain.
<?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)
(function($){
$.fn.ifdo = function(fn) {
if (this.length > 0) {
fn.call(this);
}
};
})(jQuery);
$ 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
MongoDb vs PostgreSQL (single table with 777,229 records)
--------------------------------------------------------
# Number of Records in the table
=> 777229
# Size of the Table
# PostgreSQL (Data + Indexes)
+----------------+
module CacheKey
extend self
def expirable(range = :minute, time = ::Time.current)
key = case range
when :always
::Time.current
when :never
nil
when :second
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|
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