Skip to content

Instantly share code, notes, and snippets.

@alwold
alwold / jdbcinfo.jsp
Created Apr 9, 2010
jsp to get tomcat data source info
View jdbcinfo.jsp
<%@page import="javax.naming.InitialContext"%>
<%@page import="javax.naming.Context"%>
<%@page import="javax.naming.NamingEnumeration"%>
<%@page import="javax.naming.NameClassPair"%>
<%@page import="org.apache.tomcat.dbcp.dbcp.BasicDataSource"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Driver"%>
<%@page import="java.util.Enumeration"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
View disable-ssl-validation.jsp
<%@ page import="javax.net.ssl.TrustManager" %>
<%@ page import="javax.net.ssl.SSLContext" %>
<%@ page import="javax.net.ssl.HttpsURLConnection" %>
<%@ page import="javax.net.ssl.X509TrustManager" %>
<%@ page import="javax.net.ssl.HostnameVerifier" %>
<%@ page import="javax.net.ssl.SSLSession" %>
<%
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[]{
@alwold
alwold / gist:1343324
Created Nov 6, 2011
minimal console log4j
View gist:1343324
log4j.rootLogger=error, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %-4r [%t] %-5p %c %x - %m%n
View AsyncTaskGps.java
public class AsyncTaskGps extends AsyncTask implements LocationListener {
private Location location;
@Override
protected Object doInBackground(Object... arg0) {
LocationManager lm = (LocationManager) arg0[0];
Looper.prepare();
// Request GPS updates. The third param is the looper to use, which defaults the the one for
// the current thread.
lm.requestSingleUpdate(LocationManager.GPS_PROVIDER, this, null);
View styles.xml
<style name="FindMyTrain" parent="Theme.Sherlock">
<item name="android:actionBarTabStyle">@style/FindMyTrain.ActionBar.Tab</item>
<item name="actionBarTabStyle">@style/FindMyTrain.ActionBar.Tab</item>
</style>
<style name="FindMyTrain.ActionBar.Tab">
<item name="android:background">@drawable/tab_bar_background</item>
</style>
View tab_bar_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@color/transparent"/>
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_bar_background_selected"/>
<item android:state_selected="false" android:state_pressed="true" android:drawable="@color/tab_highlight"/>
<item android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_bar_background_selected_pressed"/>
</selector>
View colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="transparent">#00000000</color>
<color name="tab_highlight">#ff9ecfbf</color>
</resources>
View tab_bar_background_selected.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#ff4ba587" android:width="5dp"/>
</shape>
</item>
</layer-list>
View tab_bar_background_selected_pressed.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#ff4ba587" android:width="5dp"/>
<solid android:color="@color/tab_highlight"/>
</shape>
</item>
</layer-list>
View AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/FindMyTrain"
android:name=".FindMyTrainApplication" >