Skip to content

Instantly share code, notes, and snippets.

View esaounkine's full-sized avatar

Ilya Saunkin esaounkine

View GitHub Profile
@esaounkine
esaounkine / SwiftMessageProcessingService.java
Last active December 25, 2015 06:29
parse a text SWIFT message using the SwiftMsgProcessor
SwiftMessage parsedSwiftMsg = new SwiftMsgProcessor().ParseMsgStringToObject(msgText)
@esaounkine
esaounkine / distance_between.sql
Created September 23, 2011 14:03
Calculate distance between two points with MySQL
CREATE FUNCTION distance_between (from_lat DECIMAL(6, 3), from_lng DECIMAL(6, 3), to_lat DECIMAL(6, 3), to_lng DECIMAL(6, 3)) RETURNS DECIMAL(11, 3)
RETURN 6371 * 2 * ATAN2(SQRT(POW(SIN(RADIANS(to_lat - from_lat)/2), 2) + POW(SIN(RADIANS(to_lng - from_lng)/2), 2) * COS(RADIANS(from_lat)) * COS(RADIANS(to_lat))), SQRT(1 - POW(SIN(RADIANS(to_lat - from_lat)/2), 2) + POW(SIN(RADIANS(to_lng - from_lng)/2), 2) * COS(RADIANS(from_lat)) * COS(RADIANS(to_lat))));
@esaounkine
esaounkine / gist:1011865
Created June 7, 2011 08:01
Offline tile layer with ArcGIS for Android - usage
map = (MapView) findViewById(R.id.map); //get the map instance
TiledLayer DAY_LAYER = new OfflineTiledLayer(this, new File(Environment.getExternalStorageDirectory(), "services"), "/RoadMapsWebMercator101010/MapServer/", "index.html", "/Day/tile/"); //create a layer
map.addLayer(DAY_LAYER); //add this layer to the map
@esaounkine
esaounkine / OfflineTiledLayer.java
Created June 7, 2011 07:53
Offline tile layer with ArcGIS for Android - bean
package com.aploon.map.esri;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParser;
import android.content.Context;
@esaounkine
esaounkine / gist:1004140
Created June 2, 2011 08:58
Global validation for a Date input field in ADF 10
protected void setAttributeInternal(int attributeNumber, Object attributeValue) {
if (attributeValue instanceof oracle.jbo.domain. Date) {
java.util.Date value = ((oracle.jbo.domain.Date)attributeValue).getValue();
GregorianCalendar gc = new GregorianCalendar();
java.util.Date inAHundreedYears = new java.util.Date(new GregorianCalendar(gc.get(Calendar.YEAR) + 100, gc.get(Calendar.MONTH), gc.get(Calendar.DAY_OF_MONTH)).getTimeInMillis());
if (value.after(inAHundreedYears)) {
System.err.println("Invalid date provided (" + value + ")");
}
else {
super.setAttributeInternal(attributeNumber, attributeValue);
@esaounkine
esaounkine / gist:959200
Created May 6, 2011 15:42
Cloudmade routing on OSMDroid - usage
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
.
.
.
BlueLine blueLine = new BlueLine(Color.BLUE, this);
}
Location lastKnownLocation;
@esaounkine
esaounkine / gist:959151
Created May 6, 2011 15:26
Cloudmade routing on OSMDroid - key
<application android:name=".App"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="true"
android:theme="@android:style/Theme.NoTitleBar">
<meta-data android:name="CLOUDMADE_KEY" android:value="API key obtained from Cloudmade"/>
.
.
.
</application>
@esaounkine
esaounkine / BlueLine.java
Created May 6, 2011 15:11
Cloudmade routing on OSMDroid
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import javax.xml.parsers.SAXParserFactory;
@esaounkine
esaounkine / gist:956756
Created May 5, 2011 08:57
Offline Google Maps on OSMDroid
org.osmdroid.views.MapView mapView = (org.osmdroid.views.MapView) findViewById(R.id.map_view); //resolve the map view by id given in the layout
mapView.setTileSource(new OnlineTileSourceBase("Google Maps", ResourceProxy.string.unknown, 1, 20, 256, ".png", "http://mt3.google.com/vt/v=w2.97") {
@Override
public String getTileURLString(final MapTile aTile) {
/*
* GOOGLE MAPS URL looks like
* base url const x y zoom
* http://mt3.google.com/vt/v=w2.97&x=74327&y=50500&z=17
*/
return getBaseUrl() + "&x=" + aTile.getX() + "&y=" + aTile.getY() + "&z=" + aTile.getZoomLevel();
@esaounkine
esaounkine / table_dialog.xml
Created April 29, 2011 12:46
Intent to start navigation activity - layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
android:id="@+id/table_dialog_header">