Skip to content

Instantly share code, notes, and snippets.

@sabadow
sabadow / Main.java
Last active June 16, 2020 16:08
Simple Heroku DB example with JSP and JDBC for DevBurgos
package com.example;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
/**
* This class launches the web application in an embedded Jetty container.
*/
public class Main {
@sabadow
sabadow / gist:2584309
Created May 3, 2012 08:22
Add a Filter on an ArrayAdapter to AutoCompleteTextView (Android)
@Override
public Filter getFilter() {
Filter myFilter = new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults filterResults = new FilterResults();
if(constraint != null) {
List<GenericProduct> filteredProducts = new ArrayList<GenericProduct>();
for(GenericProduct currentGenericProduct : genericProductList){
if(currentGenericProduct.getName().contains(constraint)){
@sabadow
sabadow / MainActivity.java
Last active July 4, 2017 11:32
Fabric time line custom adapter to overrides onClick event
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.twitter.sdk.android.Twitter;
import com.twitter.sdk.android.core.TwitterAuthConfig;
import com.twitter.sdk.android.core.models.Tweet;
@sabadow
sabadow / monkeyrunnerTestSuite.py
Created October 25, 2013 12:20
github / gauges-android monkey runner
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
# Installs the Android package. Notice that this method returns a boolean, so you can test
# to see if the installation worked.
device.installPackage('../app/target/gauges-android-1.0.apk')
@sabadow
sabadow / gist:5998086
Last active December 19, 2015 18:19
Create a release (based on robovm project)
  • Create release branch:
git branch rb-<version>
  • Update the master branch to the next -SNAPSHOT version:
mvn -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=-SNAPSHOT
@sabadow
sabadow / gist:4274923
Created December 13, 2012 08:10
Image with rounded corners by Romain Guy
BitmapShader shader;
shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(shader);
RectF rect = new RectF(0.0f, 0.0f, width, height);
// rect contains the bounds of the shape
@sabadow
sabadow / BitmapHelper.java
Created October 31, 2012 15:24
Android BitmapHelper
import java.io.InputStream;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class BitmapHelper {
public static int calculateInSampleSize(BitmapFactory.Options options,int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
@sabadow
sabadow / gist:3841866
Created October 5, 2012 19:33
Example of rounded image with inline css
<img style="border-radius: 30px;"
src="http://static.myopera.com/community/graphics/speeddials/Opera-Background-Colored-Lights.jpg"/>
@sabadow
sabadow / gist:1788703
Created February 10, 2012 10:44
Check if Android Intent is available
/**
* Check if an Intent is available to use
* @param intent the Intent to check if is available
* @return true if is available, false otherwise
*/
private boolean isIntentAvailable(Intent intent) {
List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
@sabadow
sabadow / gist:1778654
Created February 9, 2012 09:12
Launch Twitter official client from Android through an Intent
Intent tweetIntent = new Intent(Intent.ACTION_SEND);
tweetIntent.putExtra(Intent.EXTRA_TEXT, "This is a Test.");
tweetIntent.setType("text/plain");
PackageManager packManager = getPackageManager();
List<ResolveInfo> resolvedInfoList = packManager.
queryIntentActivities(tweetIntent, PackageManager.MATCH_DEFAULT_ONLY);
boolean resolved = false;
for(ResolveInfo resolveInfo: resolvedInfoList){