Skip to content

Instantly share code, notes, and snippets.

View adriaant's full-sized avatar

Adriaan Tijsseling adriaant

View GitHub Profile

Keybase proof

I hereby claim:

  • I am adriaant on github.
  • I am adriaangt (https://keybase.io/adriaangt) on keybase.
  • I have a public key ASB0AsPKGaLSoMH2hjWliZYJnLwvUzfdMckrMCYmDqqouwo

To claim this, I am signing this object:

# Originally from marc-w.com
# Built and tested on Django 1.6
from django.db import connection, transaction
class BulkInsertManager(models.Manager):
def _bulk_insert_ignore(self, create_fields, values, print_sql=False):
'''
import sys
import os
import zlib
from urllib2 import (build_opener, HTTPPasswordMgrWithDefaultRealm,
HTTPBasicAuthHandler, HTTPDigestAuthHandler, HTTPError, URLError)
from httplib import BadStatusLine
class HTTPHandlerError(Exception):
"""
@adriaant
adriaant / em-synchrony-iterator_hang.rb
Created January 8, 2011 12:28
EM::Synchrony::Iterator vs Typhoeus::Hydra benchmark
require 'em-synchrony'
require 'em-synchrony/em-http'
require 'em-synchrony/iterator'
require 'benchmark'
require 'typhoeus'
# Sample urls can be found in https://gist.github.com/770794
urls = []
File.open('urls.txt', 'r+') do |f|
urls = f.readlines
@adriaant
adriaant / urls.txt
Created January 8, 2011 12:27
Sample urls for em-synchrony-iterator_hang.rb
http://4sq.com/b9IRWk
http://4sq.com/gT1S4V
http://4sq.com/hS5b0S
http://74limelane.com.au/blog/2011/01/06/a-berry-fun-afternoon/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+74LimeLane+(74+Lime+Lane)&utm_content=Google+Reader
http://aphlogin.com/aff_c?aff_id=33380&offer_id=4948
http://aphlogin.com/aff_c?aff_id=33380&offer_id=63695
http://aphlogin.com/aff_c?aff_id=33380&offer_id=100182
http://armageddonexpo.com/au/
http://becomeanauctioneer.com.au/charity-benefit-auctioneer-the-best/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+Becomeanauctioneer+(becomeanauctioneer.com.au)
http://becomeanauctioneer.com.au/father-time-auction-service-estate-auctions-real-estate-auctioneers/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+Becomeanauctioneer+(becomeanauctioneer.com.au)
@adriaant
adriaant / nethttp_vs_restclient.rb
Created November 26, 2010 01:22
rest-client gem is too slow
#!/usr/bin/env ruby
require 'rest_client'
require 'net/http'
require 'benchmark'
time = Benchmark.realtime do
url = URI.parse('http://bit.ly/4okpb2')
req = Net::HTTP::Head.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) }
end
['rubygems', 'pathname', 'zip/zip', 'fileutils'].each {|x| require x}
UUIDchars = ("a".."f").to_a + ("0".."9").to_a
def uuid_seg(len)
ret = ""
1.upto(len) { |i| ret << UUIDchars[rand(UUIDchars.size-1)] }; ret
end
def random_uuid
"#{uuid_seg(8)}"
end