Skip to content

Instantly share code, notes, and snippets.

View ursimon's full-sized avatar

Michal Ursiny ursimon

View GitHub Profile
@ursimon
ursimon / RxJavaExample.java
Created February 15, 2017 15:54 — forked from antslava/RxJavaExample.java
RxJava share()
package com.antmobile.java;
import rx.Observable;
import rx.Subscriber;
import rx.schedulers.Schedulers;
public class FirstTempClass {
public static void main(String[] args) {
final Observable<Long> observable = Observable.create(new Observable.OnSubscribe<Long>() {
@ursimon
ursimon / LayoutTransition.CHANGING
Created July 28, 2014 11:29
Setting layout transitions for changes ANDROID
if (Build.VERSION.SDK_INT>=16) { // this is only for Jelly Bean and up
LinearLayout container = (LinearLayout) getView().findViewById(R.id.container);
LayoutTransition transition = container.getLayoutTransition();
transition.enableTransitionType(LayoutTransition.CHANGING);
}
@ursimon
ursimon / gist:9250309
Created February 27, 2014 13:47
Imagick quickly resize
for f in *.png; do convert $f -resize 400x210 $(basename $f .png).png;done
@ursimon
ursimon / gist:9249338
Created February 27, 2014 12:43
Imagick batch convert command line (from tif->png)
for f in *.tif; do convert $f $(basename $f .tif).png;done
@ursimon
ursimon / launchMap.java
Created February 10, 2014 09:44
Launch google map w/ marker
/**
* starts google maps w/ lat lon
*/
public static void showOnMap(Context c, double lat, double lng, String name) {
String geoUri = "geo:"+lat+","+lng+"?q="+lat+","+lng+"("+name+")";
Uri geo = Uri.parse(geoUri);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geo);
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
if (intent.resolveActivity(c.getPackageManager()) != null) {
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.*;
import android.util.AttributeSet;
import com.android.volley.toolbox.NetworkImageView;
public class FadeInNetworkImageView extends NetworkImageView {
private static final int FADE_IN_TIME_MS = 250;
@ursimon
ursimon / computeMD5Hash.java
Created January 21, 2014 13:00
computes MD5 hash
public String computeMD5Hash(String password)
{
try {
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(password.getBytes());
byte messageDigest[] = digest.digest();
StringBuffer MD5Hash = new StringBuffer();
for (int i = 0; i < messageDigest.length; i++)
@ursimon
ursimon / openweb.java
Created January 17, 2014 14:33
Open Web Url Intent
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
@ursimon
ursimon / GsonRequestHeaders.java
Created December 2, 2013 00:42
GsonRequest w/ support for headers and body
/**
* Copyright 2013 Ognyan Bankov
* modified by Michal Ursiny for purposes of Fuerte Eshop adding headers and body support
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@ursimon
ursimon / autoincrement.py
Created October 9, 2013 15:23
python script to auto-increment AndroidManifest.xml versionName + versionCode
#!/usr/bin/python
from xml.dom.minidom import parse
dom1 = parse("AndroidManifest.xml")
oldVersion = dom1.documentElement.getAttribute("android:versionName")
oldVersionCode = dom1.documentElement.getAttribute("android:versionCode")
versionNumbers = oldVersion.split('.')
versionNumbers[-1] = unicode(int(versionNumbers[-1]) + 1)
dom1.documentElement.setAttribute("android:versionName", u'.'.join(versionNumbers))