Skip to content

Instantly share code, notes, and snippets.

View Premier's full-sized avatar

Premier Premier

View GitHub Profile
@Premier
Premier / How to use in Spring controller
Created June 29, 2013 19:20
PDFBox is a library to create PDF document on-the-fly. It offers a lot of feature to generate page, read existing pdf document text and draw on blank template. This gist offers an example to generate a table in pdf document with PDFBox
try {
ByteArrayOutputStream output = new ByteArrayOutputStream();
output = createPDF();
response.addHeader("Content-Type", "application/force-download");
response.addHeader("Content-Disposition", "attachment; filename=\"yourFile.pdf\"");
response.getOutputStream().write(output.toByteArray());
}
catch (Exception ex) {
ex.printStackTrace();
}
@Premier
Premier / CSS
Created June 29, 2013 19:24
CSS only to create a layout similar to Pinterest with floating cards.
body {
background: url(http://subtlepatterns.com/patterns/scribble_light.png) ;
}
#wrapper {
width: 90%;
max-width: 1100px;
min-width: 800px;
margin: 50px auto;
}
@Premier
Premier / pom.xml
Created July 1, 2013 16:28
Define a different property file for log4j in maven test
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>pertest</forkMode>
<!-- this is what triggers the problem, having it to "never" works also -->
<systemProperties>
<property>
<name>log4j.configuration</name>
<value>file:target/test-classes/log4j.xml</value>
@Premier
Premier / console
Created July 1, 2013 16:30
The tests will automatically pause and await a remote debugger on port 5005. You can then attach to the running tests using Eclipse. You can setup a "Remote Java Application" launch configuration via the menu command "Run" > "Open Debug Dialog..."
mvn -Dmaven.surefire.debug test
@Premier
Premier / console
Created July 1, 2013 16:31
Remove android app from console
First,make sure the emulator is running.Then follow below steps:
1. go to tools directory in command
2. adb shell
3. cd /data/app
4. ls (It will display all the .apk installed in your emulator)
5. rm ***.apk(which you want to remove)
6. exit
@Premier
Premier / layout
Created July 8, 2013 10:13
Create a form with fixed buttons and fields in scrollview
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_alignParentBottom="true"
@Premier
Premier / Point
Created July 10, 2013 21:57
Simple implementation of Android Parcelable
import android.os.Parcel;
import android.os.Parcelable;
public class Point implements Parcelable{
private int x;
private int y;
public Point(int x, int y) {
this.x = x;
@Premier
Premier / activity
Created July 10, 2013 22:02
Simple Android TextView scrollable
yourTextView.setMovementMethod(new ScrollingMovementMethod())
@Premier
Premier / bash
Created July 11, 2013 15:26
Maven command to generate appengine project
mvn archetype:generate -DarchetypeGroupId=com.google.appengine.archetypes -DarchetypeArtifactId=guestbook-archetype -DarchetypeVersion=1.7.4
@Premier
Premier / shell
Created July 11, 2013 21:36
Maven plugin's description
mvn help:describe -Dplugin=appengine