Skip to content

Instantly share code, notes, and snippets.

View galex's full-sized avatar

Alexander Gherschon galex

View GitHub Profile
@galex
galex / post-receive
Created November 27, 2009 13:35
File to put in each git-repository/hooks/ folder, for each project, to notifity Integrity to get this new build and test it.
#!/usr/bin/env ruby
# Replace the following by the url given to you in your project's edit page
POST_RECEIVE_URL = 'http://integrity.url.com/project_name/push'
# Set user and password if Integrity is protected with basic auth
USER = "***"
PASSWORD = "***"
#######################################################################
// problem when closing the app, this one crashed without any reason
bindService(new Intent(this, PlayerService.class), this.playerServiceConnection, Context.BIND_AUTO_CREATE);
// solution
bindService(new Intent(this, PlayerService.class), this.playerServiceConnection, Context.BIND_DEBUG_UNBIND);
@galex
galex / gist:631791
Created October 18, 2010 05:51
android app blocks device from going into sleep/stand by mode
public class MyActivity extends Activity {
// define the wakeLock as attribute
PowerManager.WakeLock wakeLock ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
@galex
galex / gist:631844
Created October 18, 2010 07:05
geotoolkit-lambert72-to-wgs84
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:9803") ;
CoordinateReferenceSystem targetCRS = DefaultGeographicCRS.WGS84;
MathTransform tr = CRS.findMathTransform(sourceCRS, targetCRS);
DirectPosition sourcePt = new GeneralDirectPosition(coordinates.getDouble(0), coordinates.getDouble(1), 0);
DirectPosition targetPt = tr.transform(sourcePt, null);
System.out.println("Source point: " + sourcePt);
System.out.println("Target point: " + targetPt);
@galex
galex / gist:631879
Created October 18, 2010 07:38
Converts Lambert72 coordinates to WGS84 coordinates
public static Point lambert72toWGS84(double x, double y) {
double newLongitude;
double newLatitude;
double n = 0.77164219;
double F = 1.81329763;
double thetaFudge = 0.00014204;
double e = 0.08199189;
double a = 6378388;
@galex
galex / gist:631894
Created October 18, 2010 07:59
geographical point
package be.agherschon.moveinbxl.maps;
/**
* Represents a geographical point.
* As it is used with Google Maps, it has two more getters, which returns the values in x^E6.
* @author Alexandre Gherschon
*/
public class Point {
private double latitude ;
private double longitude;
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(this.getResources().getString(R.string.no_internet_dialog_title));
alertDialog.setMessage(this.getResources().getString(R.string.no_internet_dialog_message));
alertDialog.setCancelable(false);
alertDialog.setButton(this.getResources().getString(R.string.no_internet_dialog_button_text), new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// I just close the app if there is no internet connection
OxydroidActivity.this.finish();
http://myapp.com/users.xml
@galex
galex / .classpath
Created December 14, 2011 08:16
Correct .classpath file for Android source code (master)
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="packages/apps/Bluetooth/src"/>
<classpathentry kind="src" path="packages/apps/Browser/src"/>
<classpathentry kind="src" path="packages/apps/Calendar/src"/>
<classpathentry kind="src" path="packages/apps/Calculator/src"/>
<classpathentry kind="src" path="packages/apps/Camera/src"/>
<classpathentry kind="src" path="packages/apps/CertInstaller/src"/>
<classpathentry kind="src" path="packages/apps/Contacts/src"/>
<classpathentry kind="src" path="packages/apps/DeskClock/src"/>
@galex
galex / security.rb
Created August 2, 2012 05:01
Android in-app billing signature validation on server side
class Android
def self.verify(data , sig)
official_key = "mykeygoeshere"
key = OpenSSL::PKey::RSA.new(Base64.decode64(official_key))
verified = key.verify( OpenSSL::Digest::SHA1.new, Base64.decode64(sig), data )
end
end
end