Feb 25, 2014

OpenStreetMaps layer in Google Maps API V3

Adding an OSM layer in Google Maps is very easy, since the V3 API provides a functionality for adding custom layers (even WMS!).

First, you need to define custom map settings, to include your layer. It's good to change the layer chooser to 'dropdown' too.
map = new google.maps.Map(document.getElementById("gmap_canvas"), {
 scaleControl: true,
 mapTypeId: google.maps.MapTypeId.ROADMAP,
 mapTypeControlOptions: {
  mapTypeIds: [
   "OSM",
   google.maps.MapTypeId.ROADMAP, 
   google.maps.MapTypeId.SATELLITE, 
   google.maps.MapTypeId.HYBRID, 
   google.maps.MapTypeId.TERRAIN
  ],
  style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
 }
});
Next, you define your OSM layer like so:
map.mapTypes.set("OSM", new google.maps.ImageMapType({
 getTileUrl: function(coord, zoom) {
  return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
 },
 tileSize: new google.maps.Size(256, 256),
 name: "OSM",
 maxZoom: 18
}));
And there you go. You can check the demo out at: http://poi.kafol.net/


Nov 24, 2013

YouTube Full Screen Problem (video doesn't stretch)


Are you tired of seeing this shit on YouTube Full Screen Video?

When clicking on the fullscreen button, the video stretches to about 3/4 of the screen, and the rest is black, so it's not really full screen at all. The hiccup is just in the graphics, because the controls (X Y positions of the buttons) are correct - in the corner on the screen, not where they are displayed.

This problem occurs in Google Chrome, and it's a problem with the Flash Player. To fix it, you need to go to the URL chrome://plugins/ in Chrome, and disable this plugin:


Location:C:\Users\Jean\AppData\Local\Google\Chrome\Application\31.0.1650.57\PepperFlash\pepflashplayer.dll
Type:PPAPI (out-of-process)



Disabled:



Refresh the page and...

Et voilĂ !






Nov 20, 2013

Measuring RaspberryPI CPU, GPU temperature and CPU frequency on Raspbian Linux

We'll create bash script:
sudo nano temp.sh

Paste this and save:
#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))
cpuFreq=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq | sed 's/.\{3\}$//'`Mhz

echo CPU temp"="$cpuTemp1"."$cpuTempM"'C"
echo GPU $(/opt/vc/bin/vcgencmd measure_temp)
echo CPU frequency=$cpuFreq

Set permission and run it:
sudo chmod +x temp.sh;./temp.sh


Bash script domain expiration check tool Slovenian version

This script checks if domain has expired and also supports e-mail notice. 

Original script is from Matt (domain-check). I modifed already modified script from Vivek (http://www.cyberciti.biz/tips/domain-check-script.html).


List of changes:


- Added support for Slovenian (.si) domains.

- Added VAR for "mail from:".
- Increased time between whois queries to 7 seconds (Slovenian whois only allows 10 queries per minute).
- Mail subject and mail data are translated to Slovene language.
- Changed default VAR path for mail (/bin/mail/ to /usr/bin/mail)

Get the script:
wget http://krejzi.si/files/domain-check;mv domain-check domain-check.sh;chmod +x domain-check.sh

Usage:
Usage: ./domain-check.sh [ -e email ] [ -x expir_days ] [ -q ] [ -a ] [ -h ]
          {[ -d domain_namee ]} || { -f domainfile}

  -a                                        : Send a warning message through email
  -d domain                            : Domain to analyze (interactive mode)
  -e email address                   : Email address to send expiration notices
  -f domain file                        : File with a list of domains
  -h                                         : Print this screen
  -s whois server                     : Whois sever to query for information
  -q                                         : Don't print anything on the console
  -x days                                 : Domain expiration interval (eg. if domain_date < days)


Check single domain:
./domain-check.sh -d domain.si

Check single domain and send e-mail notice if domain will expire in less than defined in WARNDAYS:

./domain-check.sh -a -d domain.si

You can also check multiple domains. Create a file domains.txt and add your domains like:


domain1.com

domain2.com
domain3.com

Check multiple domains:
./domain-check.sh -f domains.txt

Check multiple domains and send e-mail notice if any domain will expire in less than defined in WARNDAYS:

./domain-check.sh -a -f domains.txt

Set your own parameters from command line. Next command will check domains in domains.txt with expiration date less than 60 days and send e-mail notice to admin@domain.si

./domain-check.sh -a -f domains.txt -e admin@domain.si -x 60 

If you are going to use this script with cron, use -q option or change QUIET="FALSE" to QUIET="TRUE"

Let's say we want to run this script every day at 4 AM. Open crontab with crontab -e (Ubuntu) and add the following line:
0 4 * * * /path/to/your/script/domain-check.sh -q -a -f /path/to/your/list/domains.txt

Nov 15, 2013

Postfix SSL error when sending message in Thunderbird client

This is a repost from my old blog that is no longer available. (May 16th 2012)

I was trying to send an email with Thunderbird client and got SSL TLS error message. I instantly suspected my email server crashed, because I had to force reboot a day ago.

After tailing mail.log this error message appeared:

postfix/smtpd[1834]: warning: TLS library problem: 1834:error:14094417:SSL routines:SSL3_READ_BYTES:sslv3 alert illegal parameter:s3_pkt.c:1093:SSL alert number 47:

When investigating further I found out mail server was fine, the main reason for this error was on guest machine (where thunderbird was installed - windows 7), it was Avast antivirus. Disabling and re-enabling it was the solution.