wtorek, 2 grudzień 2008

Looking for new job

From 1st January 2009 I'm looking for new job (current company close polish office). If you know any nice company who wants hire, let me know jagiello.lukasz@gmail.com. My Curriculum Vitae (PDF)

Amazon CloudFront in Ruby

Last month Amazon launch new service - Amazon CloudFront. Amazon CloudFront delivers your content from Amazon S3 using a global network of edge locations. Sweet, really nice solution for quite expensive Akamai (yes, I know Akamai is cheaper at some level, but startups don't have such budget). At start they release only Amazon CloudFront Authentication Tool for Curl. So decide to wrote own tool in ruby (atm there is RightScale Ruby library but when I wrote that there wasn't any such tool).

First, I try use curb (Libcurl bindings for Ruby), but then notice that can be done more simple only with Net::HTTP

According to Developer Guide correct REST Requests needs URI indicates the particular resource you want to act on, also needs correct Request Headers (Authorization, Content-Length, Content-Type, Date, Host, x-amz-date).

Date/x-amz-date like at provided by Amazon curl script, get from Amazon server:

def self.server_date(url)
server_date=''
uri = URI.parse(url)
http = Net::HTTP.new(uri.host,443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response=http.request_get(uri.path)
response['Date']
end


Authorization generate as Amazon documentation said:

def self.sign(date)
digest = OpenSSL::Digest::Digest.new('sha1')
hmacd=HMAC.new(AWS_SECRET_ACCESS_KEY, digest)
hmacd.update(date)
signature=Base64.encode64(hmacd.digest)
end


So simple list distribution can be done like that:

def ACFList(url)
date=server_date(url)
uri = URI.parse(url)
http = Net::HTTP.new(uri.host,443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
headers = {
'X-AMZ-Date' => date,
'Authorization' => 'AWS ' + AWS_ACCESS_KEY_ID + ':' + sign(date).chop
}
response=http.request_get(uri.path,headers)
response
end


Example:

./acf.rb list https://cloudfront.amazonaws.com/2008-06-30/distribution
<?xml version="1.0"?>
<DistributionList xmlns="http://cloudfront.amazonaws.com/doc/2008-06-30/"><Marker></Marker><MaxItems>100</MaxItems><IsTruncated>false</IsTruncated></DistributionList>


Hole code can be find here

poniedziałek, 1 grudzień 2008

Kreatywna matematyka według Tesco

Dzisiaj w Tesco odkryłem nową, kreatywną wersje matematyki. Idąc między regałami zauważyłem:



Ser Philadelphia - 3,29zł (ta mała cena po lewej stronie). Promocja 2 sztuki za 6zł. Niby ok, jest promocja jest dobrze. Niepokoi mnie tylko informacja "Oszczędzasz 6zł"

WTF ?!?

2x3,29zł = 6,58zł
- 6,00zł
-----------------
0,58zł (nijak 6zł nie wychodzi)

Idąc za ciosem zrobiłem jeszcze kilka zdjęć:



czwartek, 13 listopad 2008

Less spam ? Yeah McColo's is down.

Really interesting news read today. According to Boris Veldhuijzen van Zanten spam levels fell by 66% after Tuesday. That happened after Internet providers cut off McColo’s (Site is down) connectivity to the Internet.



Incredible isn't it ?

czwartek, 30 październik 2008

Dj Wonter - Wings - Official Music Video

Wicked tune made by Wonter. Check it !