Sunday 7 October 2012

Ukarainian Way of Rotating IPs

Note: original IP addresses are changed to the fake ones according to RFC 5737.

Once upon a time one of my ex-employers texted me a call for help. A recently installed dedicated server used to go offline time after time.

Challenge accepted.

Wednesday 23 May 2012

Rounding. The Way of Python

I cried a dozen of bloody tears trying to understand why the heck guys had it done this particular way.
Well, no more comments here. Just a hint: this piece of code is taken from a very enterprise UI and is supposed to round val with precision rdig. I'm not really a Python evangelist or something but isn't there anything around that rounds numbers?
   fmt = "%%.0%df" % rdig

   # Do rounding
   m = 1.0
   while rdig > 0:
      m *= 10.0
      rdig -= 1

   val = int(val * m + 0.5) / m
   val = fmt % val

Friday 27 April 2012

Indians Detected!

Once upon a time a link to some Java tutorials crossed my Skype history.
Let's try to share weird feeling I felt after I had looked through examples. There were Latin letters (I'm pretty sure of it), English-looking words (again, for sure) but they tried to express some delicate contents of Indian soul:
Well, guys definitely rock. They gained double profit at once: daily prayer and examples for coding tutorial.
Just in case: that's something called Coding Diary.
And yes, I think that Java (or C#, maybe) is about to become one of the official languages in India.

Wednesday 25 April 2012

Were We Redirected?

I found this one in a custom piece of shit software (luckily, not in a widespread CMS or something). That was a grabber. Sure, there were some redirects while crawling websites. And, ladies and gentlemen…
The most stupid way to check for redirect I've ever seen:
stripos($result, "<head><title>Document Moved</title></head>") !== FALSE

Then guy tries to figure out what's the address he's been sent to:
reg_match( "#(?i)<a HREF=\"(.+?)\">#", $result, $href );
Nothing to add, really. Enough said.

Tuesday 24 April 2012

Rewrite Rules From phpprobid's .htaccess

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

RewriteRule ^(.*),(.*)$ $2.php?rewrite_params=$1&page_url=$2  


Which is more weird, this shit costs a fortune (well, not exactly a fortune, but way too much considering its crappiness) and tends to be “Professional Auction Script Software”, my arse!