Skip to content

Instantly share code, notes, and snippets.

View libinbensin's full-sized avatar

Libin libinbensin

  • United States
View GitHub Profile
/* Base fragment to ensure the parent activity implements a contract interface. */
public abstract class ContractFragment<T> extends Fragment {
private T mContract;
@Override
public void onAttach(Activity activity) {
try {
mContract = (T)activity;
} catch (ClassCastException e) {
throw new IllegalStateException(activity.getClass().getSimpleName()
@libinbensin
libinbensin / AndroidManifest
Created May 5, 2014 22:49
Android close all below Activities
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppBaseTheme"
android:name=".MyApp">
@libinbensin
libinbensin / AndroidManifest.xml
Created May 9, 2014 01:53
Widget with Service (Custom Action)
/** change the service in manifest to receive custom action **/
<service android:name="com.stackwork.app.services.CustomService" >
<intent-filter>
<action android:name="com.mediabook.app.ACTION_PLAY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
@libinbensin
libinbensin / HorizontalListView.java
Created May 9, 2014 20:42
HorizontalListView to add items horizontally
import android.content.Context;
import android.database.DataSetObserver;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Adapter;
import android.widget.BaseAdapter;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')
@libinbensin
libinbensin / StartTomcat.txt
Last active August 29, 2015 14:26
Start Apache Tomcat at boot on Mac OS X
This is for installing tomcat as a daemon on port 8080 but enable also port 80 by using a firewall redirection.
Edit /Library/Tomcat/conf/server.xml and add proxyport="80" URIEncoding="UTF-8" inside <Connector .../>.
<Connector proxyport="80" URIEncoding="UTF-8" />
Assign enough memory to the Java machine or you may be in trouble later. Inside /Library/Tomcat/conf/local.env
export JAVA_JVM_VERSION=CurrentJDK
export JAVA_OPTS="-Xmx3000M -Xms3000M -Djava.awt.headless=true -Duser.timezone=UTC"
@libinbensin
libinbensin / InstallTomcat
Created July 31, 2015 01:21
Installing Tomcat
Here are the easy to follow steps to get it up and running on your Mac
Download a binary distribution of the core module: apache-tomcat-7.0.47.tar.gz from here. I picked the tar.gz in Binary Distributions / Core section.
Opening/unarchiving the archive will create a folder structure in your Downloads folder: (btw, this free Unarchiver app is perfect for all kinds of compressed files and superior to the built-in Archive Utility.app)
~/Downloads/apache-tomcat-7.0.47
Open to Terminal app to move the unarchived distribution to /usr/local
sudo mkdir -p /usr/local
sudo mv ~/Downloads/apache-tomcat-7.0.47 /usr/local
@libinbensin
libinbensin / card_layout
Created September 23, 2015 01:46 — forked from biokys/card_layout
Card layout with bottom shadow
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle"
android:dither="true">
<corners android:radius="@dimen/card_corner_radius"/>
<solid android:color="#bbb" />
</shape>
@libinbensin
libinbensin / deploy-static-site-heroku.md
Created May 29, 2016 06:07 — forked from wh1tney/deploy-static-site-heroku.md
How to deploy a static website to Heroku

Gist

This is a quick tutorial explaining how to get a static website hosted on Heroku.

Why do this?

Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app. This 6-step tutorial will teach you how.

Basic Assumptions

@libinbensin
libinbensin / MediaPlayerStateWrapper.java
Created October 31, 2015 05:49 — forked from bitops/MediaPlayerStateWrapper.java
A drop-in replacement for a MediaPlayer instance, that provides an accessor for the current state.
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import android.media.AudioManager;
import android.media.MediaPlayer;