Skip to content

Instantly share code, notes, and snippets.

View Premier's full-sized avatar

Premier Premier

View GitHub Profile
@Premier
Premier / sql
Created September 3, 2013 08:54
Ignorare vincoli di integrità referenziale per cancellare tabella in mysql
SET foreign_key_checks = 0;
-- Drop tablesdrop table ...
-- Drop viewsdrop view ...
SET foreign_key_checks = 1;
@Premier
Premier / HttpClient
Created July 31, 2013 17:52
Classe per generare url con parametri/segmenti
HttpPost request = new HttpPost(UriComponentsBuilder
.fromHttpUrl(restBaseUrl)
.pathSegment("auth", "request_token")
.build()
.toUriString());
@Premier
Premier / adapter
Created July 27, 2013 20:10
La classe View ci consente - tramite il metodo setTag() - di associare un oggetto alla propria istanza di classe. Nel nostro caso abbiamo creato la classe ViewHolder che utilizzeremo per mantenere i riferimenti alle textview del nome e del numero di telefono. Cosi facendo possiamo mantenere i riferimenti solo alla prima invocazione del metodo ge…
public class CustomAdapterOptimize extends ArrayAdapter<Contatto> {
public CustomAdapterOptimize(Context context, int textViewResourceId,
List<Contatto> objects) {
super(context, textViewResourceId, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return getViewOptimize(position, convertView, parent);
@Premier
Premier / spring-security.xml
Created July 27, 2013 17:28
Configurazione della persistenza del contesto di sicurezza di Spring Security. Con la seguente configurazione il contesto di sicurezza di Spring è accessibile anche in thread separati (lanciati come thread nuovi o tramite metodi annotati con @async), lanciati dopo la classica HTTP request (la quale accede al contesto di SpringSecurity in virtù d…
<beans:bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" p:targetClass="org.springframework.security.core.context.SecurityContextHolder"
p:targetMethod="setStrategyName" p:arguments="MODE_INHERITABLETHREADLOCAL" />
@Premier
Premier / shell
Created July 11, 2013 21:36
Maven plugin's description
mvn help:describe -Dplugin=appengine
@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 / activity
Created July 10, 2013 22:02
Simple Android TextView scrollable
yourTextView.setMovementMethod(new ScrollingMovementMethod())
@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 / 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 / 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