dexxtr blog

Web, mobile and other strangeness around me.
Recent Tweets @dexxtr
Posts I Like

If you guys want to determine whether your particular point is inside circle I hope MySQL query bellow can help you. You should know center of the circle (coordinates) and circle radius (kilometers).

Coordinates of circle’s center stored like point MySQL type, so the query will be like this

SELECT 
    *
FROM 
    `locator`
WHERE
    SQRT(POW(X(`center`) - 49.843317 , 2) + POW(Y(`center`) - 24.026642, 2)) * 100 < `radius`
And if you keep coordinates in separated table columns you should use this query 
SELECT 
    *
FROM
    `locator`
WHERE
    SQRT(POW(`center_lat` - 49.843317 , 2) + POW(`center_lng` - 24.026642, 2)) * 100 < `radius`

49.843317 & 24.026642 are point coordinates inside or outside the circle. We will know this exactly after execute the query.

This data visualization of Air Traffic in Europe was created from real flight data. It shows the air traffic which flies on a typical summer day and highlights the intensity of the operation in Europe - an operation which runs 24x7x365.

imageGuys, we are glad to announce about launching beta version of JobsMap soon. If you want to be one of those lucky guys who will try our service first then go to http://jobsmap.co and leave us your email. We will inform you about delivery.

image Hi everyone. I want to show you how you can encrypt any plain text using blowfish algoritm and decrypt it as well. Take a look below and you can see 2 simple methods that make this magic. This algorytm does not use vectors (IV)!

Read More

image The default supported type of screen density is MDPI, that has 160 dots per inch (DPI). Whether you have an image and you want to scale it for any screens with different density, you should put image to drawable-mdpi folder. After launch the application, android will scale this mdpi image for low, high and extra high screen size automatically. Take a look to screen types, scaling factors and screen densities bellow.

Read More

Рейтинг мобильных ОС на украинском рынке от операторов мобильной связи. Взято с Forbes UA.

Hi there.

Just implement a short peace of PHP code for sending PUSH message to Android device. If you need only to send message and check how Google Cloud Messaging service working on your device, try code bellow.

You should only change $reg_id value to your valid registration ID (onRegistered() in GCMBaseIntentService).

<?php
define("GOOGLE_API_KEY", "AIzaSyCJiVkatisdQ44rEM353PFGbia29mBVscA");
define("GOOGLE_GCM_URL", "https://android.googleapis.com/gcm/send");

function send_gcm_notify($reg_id, $message) {
 
    $fields = array(
		'registration_ids'  => array( $reg_id ),
		'data'              => array( "message" => $message ),
	);
				
	$headers = array(
		'Authorization: key=' . GOOGLE_API_KEY,
		'Content-Type: application/json'
	);
	
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, GOOGLE_GCM_URL);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

	$result = curl_exec($ch);
	if ($result === FALSE) {
		die('Problem occurred: ' . curl_error($ch));
	}

	curl_close($ch);
	echo $result;
 }
	
$reg_id = "APA91bHuSGES.....nn5pWrrSz0dV63pg";
$msg = "Google Cloud Messaging working well";

send_gcm_notify($reg_id, $msg);

Enjoy :)

Часто надо и постоянно забываю как оно делается :)

У нас уже есть android application и есть к ниму сертификат (keystore), для того чтоб из этого сертификата получить fingerprint необходимо выполнить следующую команду (Windows):

C:\Program Files\Java\jdk1.6.0_33\bin>keytool.exe -list -keystore D:\Projects\...\example.keystore
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry
example app, 26 сх 2013, PrivateKeyEntry,

Certificate fingerprint (MD5): DD:01:C3:CC:4......

C:\Program Files\Java\jdk1.6.0_33\bin>

Это для получения MD5 fingerprint’a (java 1.6), а для получения SHA1 fingerprint’a (java 1.7) необходимо выполнить следующее:

C:\Program Files (x86)\Java\jre7\bin>keytool.exe -list -keystore D:\Projects\...\example.keystore
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry
example app, 26 сх 2013, PrivateKeyEntry,

Certificate fingerprint (SHA1): DD:01:C3:CC:4......

C:\Program Files (x86)\Java\jre7\bin>