Disappearing polylines in Google Maps

Google No Comments

Recently, I have been playing with Google Maps API at my work. With the API I created a polyline but it disappears on random fashion at different zoom levels. It tooks me days to figure it out why. The main problem was I used numeric strings (i.e. numbers in quotes).

Check this examples:

  1. new GPolyline.fromEncoded({
  2.   color: "#0000ff",
  3.   weight: "4",
  4.   opacity: "0.8",
  5.   points: "_gkxEv}|vNM]",
  6.   levels: "PP",
  7.   zoomFactor: "2",
  8.   numLevels: "18"
  9. });
  1. new GPolyline.fromEncoded({
  2.   color: "#0000ff",
  3.   weight: 4,
  4.   opacity: 0.8,
  5.   points: "_gkxEv}|vNM]",
  6.   levels: "PP",
  7.   zoomFactor: 2,
  8.   numLevels: 18
  9. });

They look the same but the first one has numeric strings. I did some testing and value of the weight attribute is important!

If the value of the weight attribute is numeric string your polylines will randomly disappear.

I didn’t know that this can be so different.

I want to share my experience with you and make a note to my self.

Stop Software Patents

Uncategorized No Comments

Stop Software Patents

Best Video Ever - Wheee! by Jeff Gill

Humor No Comments

This is the most popular firefox flick made by Jeff Gill

Protect your FreeBSD box!

FreeBSD, PHP 1 Comment

I made this simple PHP script because I was tired of getting 400KB security run output emails from my FreeBSD box. It’s written in PHP because I’m not good in shell scripting.

Every minute it checks for line like this

  1. Feb  5 01:40:02 kyle sshd[939]: Failed password for root from 80.86.75.67 port 11807 ssh2

in the auth.log and grabs the IP address. If there is more than 3 failed logins from 1 IP address in one minute it is added to the firewall. I’m using the ipfw firewall.

  1. <?php
  2. // Both your server and this script must share the same timezone
  3. date_default_timezone_set('Europe/Bratislava');
  4.  
  5. // Get the last minute.
  6. // We need this because when we run this script from the cron
  7. // it starts at zero seconds and the log file will have not any entries.
  8. $lastminute = mktime(date('G'), date('i') - 1);
  9.  
  10. // Get the lines with failed logins for last minute
  11. $cmd  = '/usr/bin/more /var/log/auth.log | /usr/bin/grep "Failed password" | /usr/bin/grep "';
  12. $cmd .= date('j H:i:', $lastminute).'"';
  13. $output = shell_exec($cmd);
  14.  
  15. // Make the $output an array
  16. $output = explode("\n", $output);
  17.  
  18. // Array of IPs that you do not want to block
  19. $ignore = array('127.0.0.1');
  20.  
  21. // This array will hold IPs with failed logins
  22. $ips    = array();
  23.  
  24. // Get and count IPs
  25. foreach ($output as $line) {
  26.   $line = trim($line);
  27.   preg_match_all('/[0-9]{1,3}(\.[0-9]{1,3}){3}/', $line, $matches);
  28.  
  29.   foreach ($matches[0] as $ip) {
  30.     if (!isset($ips[$ip])) {
  31.       $ips[$ip] = 1;
  32.     } else {
  33.       $ips[$ip]++;
  34.     }
  35.   }
  36. }
  37.  
  38. // Block IPs
  39. foreach ($ips as $ip => $count) {
  40.   if ($count > 3 && !in_array($ip, $ignore)) {
  41.     $data = "/sbin/ipfw -q add 20000 deny log all from {$ip} to me";
  42.     file_put_contents('/etc/ipfw-dynamic.rules',$data, FILE_APPEND);
  43.     shell_exec($data);
  44.   }
  45. }
  46. ?>

Put this script to cron and set it to start every minute.

Google guessing drive me crazy!

Google, Me No Comments

I decided to write another post to my blog while my last post was a long time ago. After I wrote a few words I want to check if the words are correctly typed because I am not good in English. To my surprise words that I know was correct was underlined and was suggested a correction. That correction was in Slovak! (fyi I am Slovak and live in Slovakia) I have blogger set to English. I can’t make the spellchecker work as I want. Do the spellcheck in English. I cleared all cookies, set my preferred language to English and English-US in my browser, I was restarted the browser and still no luck. As I am writing this post I recognized another strange thing. You know when you are writing a post it is automatically saved as a draft. And that is the strange thing. Not the autosave feature but the message I got when it was saved. When it is autosaved I get “Draft autosaved at 2:01 AM” but when I click “SAVE NOW” I get “Koncept bol uložený o 2:04″ (which is the same as the previous one but in Slovak). I changed everything that I found on Blogger and Google to English but country.

I will not change my country just because Google doesn’t know how to handle languages.

And I am still not sure if it will help.

When I cleared all cookies I go to www.google.com and get www.google.sk. Why?? I was not logged in to my Google account. How they know that I might want sk version which I really don’t want when I have set all to English. (Well I know that my IP address tells Google I am in Slovakia.) When I type www.google.com I want www.google.com and not the sk version! When I will want sk version I will type www.google.sk!

Till Google doesn’t learn how to read my mind I suggest Google to get me what I requested instead of what Google think that I might want!

Icons by N.Design Studio. Designed By Ben Swift. Powered by WordPress and Free WordPress Themes
Entries RSS Comments RSS Log in