The Blog

Reading $_GET variable in CODEIGNITER

14 Ago 10

There are multiple solutions out there but i did create my own.

It’s simple as 1,2,3. Hope it helps.

[sourcecode lang=”php”]
// CODEIGNITER HACK
$tmp = explode(‘?’,$_SERVER[‘REQUEST_URI’]);
$tmp = explode(‘&’, $tmp[1]);

foreach($tmp as $keyval) {
$tmpAppoggio = explode(‘=’, $keyval);
$_GET[urldecode($tmpAppoggio[0])]=urldecode($tmpAppoggio[1]);
}
// end of codeigniter hack
[/sourcecode]

Add Events on Google Calendar on Android Froyo and above

09 Ago 10

Since i started developing applications for android i noticed there were some undocumented apis. Google does reccomend to not use these apis but since there are no “other nice ways” to achieve some tasks sometimes they are useful ( but still unreccomended)

It’s the case of the Google Calendar Apis. Out there you can find a lot of docs about these undocumented & unsupported apis but you’ll get some troubles if google decides to change them.

For example if you want to add an “event” to the calendar programmatically you can follow the snippet below which is SDK proof. In fact i did ( It’s not refactored for better reading ) write some code that would work on Sdk from 1.5 to 2.2 ( aka Froyo ) solving the provider issue on froyo and above.


Hope it helps to solve the problem about google calendar in froyo ๐Ÿ™‚

Reference to the CP: Xda

Android Usefull Docs

27 Lug 10

Today i surfed the web searching about guidelines and best practices on writing android apps. In this in-depth search i found some useful slides and tips:

1. Android Ui Design Guidelines

A slideshare with some usefull tips about android ui design:

[slideshare id=4827211&doc=uidesigntips-100723230420-phpapp02]

2. Android Ui Stencil and PSDs

I also found a great resource where there are some other stencils and psds to download.

Link

3. Android icon templatepack

I also noticed the Google Android team released the icon template pack so you can easily design you’r own menus and icons using their psd with a lot of presets.

Link

How to use codeigniter with eclipse helios

24 Giu 10

Codeigniter is a great framework. Eclipse is a very nice IDE. Why not using them both when writing our own apps ?

After some googling i found a way to get auto-completion with codeigniter on eclipse.

Requirements:

  1. Xampp : I suggest using xampp lite.
  2. Codeigniter: Obviously
  3. Eclipse Helios for PHP Development : ๐Ÿ™‚

Read More

Come Controllare se datePicker di jQuery รจ caricato

06 Apr 10

Penso sia piรน di una vita che non scrivo un articolo di programmazione.

Beh oggi, per lavoro, ho dovuto scrivere del codice javascript e per motivi che trascendono dallo scopo di quest’articolo ho dovuto , ad un certo punto della programmazione, controllare se datePicker era caricato.

Ci sono dei casi, infatti, che il javascript viene caricato da altri javascript e non sempre abbiamo la certezza ( Sopratutto cross-browser ) di sapere se il file js caricato progrmamaticamente รจ stato effettivamente “accettato” dal browser o meno.

Perciรฒ mi son dovuto armare di pazienza e trovare un modo per vedere se datePicker era caricato o meno.

Per completezza, nel momento in cui scrivo, ho utilizzato il datepicker v2 che trovate a questa pagina.

Ebbene, il barbatrucco รจ contenuto nella seguente riga di codice:

[javascript]
function startX() {
if ( typeof jQuery().datePicker != ‘function’) {
setTimeout(‘startX()’, 200);
return;
}
// Altro codice da inserire in caso datePicker sia stato correttamente caricato

}
[/javascript]

Ebbene, non faccio altro che controllare ogni 200 ms se datePicker รจ stato correttamente caricato e in caso positivo eseguo il codice dopo l’if.

Simple Gps Info for Android

20 Mar 10

Simple Gps Info is a simple android application that would help you know and share your gps coordinates with your android smartphone. The code is really fast and efficient and the app consist on a simple to understand layout without any kind of menu.

Once started, Simple Gps info for Android will start automatically your android gps ( Even if it’s disabled by you ) and then it will start seeking for a gps-fix.

In the meanwhile you could also look at the radar that would rotate following ย the north pole. You can try and see where is the north-pole by simply rotating your smartphone. Furthermore the radar will show you the satellites you’re smartphone is receiving.

When the Gps sensor get the fix you’ll start to see the coordinates changing and you’ll be able to share your location with your android phone.

In order to accomplish this task you’ve to push the bottom-placed button and then choose how to share it.

Right now Simple Gps info will support the following way to share the location:

  • Facebook
  • Twitter
  • Sms
  • Gmail
  • Others activity implementing text/plain content-type intent receiver.

Here are some screenshots of the first version. ( Now improved with better graphics )

If you’ve installed Barcode Scanner on your android phone you can scan this:

Google Analytics Bridge for Android developers

23 Ago 09

Google Analytics Bridge is a java library for android ( Soon to be Open Source licensedย ) that will help developers understand what the user interaction with their own application.

Google Analytics Bridge is really easy to setup and it runs on a separate thread. This is do to the problem with the internet request sometime freezing the UI and setting off the hated message:

“The Application xyz is not responing”

With the two choises :

  1. Force Close
  2. Wait

Since The Google Analytics Bridge runs on a different thread to avoid this error.

First Setup

Download and import the jar file to the application you want use the Google Analytics Bridge on.ย The setup is a fast one-line command but you need the following information:

  • Google Analytics Tracking Code ( EX: “UA-123123123-1” )
  • The Domain Name

Set up a brand new Google Analytics Profile

you will need to set up a new Google Analytics Profile or use an existing one. You will need to open a new website profile on google analytics.

The procedure is fast and simple but it does require The domain name.

In that field you can specify whatever you want, but i suggest something like:

track.your-application-name.com

After creating the new profile, copy the UA-XXXXXX-Y code for a further usage.

The Constructor

Once you’ve done all of step one it’s time to create our constructor.

In the onCreate routine place the following code:

[JAVA]new AnalyticsBridge(this.getApplicationContext(),”UA-XXXXXX-Y”,”track.your-application-name.com”);[/JAVA]

You don’t need to create an AnalyticsBridge object , after this line you will call the methods in a static way.

NOTE: You should call the constructor once per application lifetime.

Public Methods

_trackPageview(String pageTitle)

If you’ve some experience integrating google analytics on your own website you’ll also remember what this method will do.

_trackPageview method on the web it’s used for logging a new page View by the user. Similarly calling this static method on android will generate a google analytics request that will log a new Activity View.

Lets say you’ve a lot of activity, and some of theese will show the same content but in a different way, then i would put the following code on each onCreate Subroutine:

[JAVA] /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

AnalyticsBridge._trackPageview(this.getClass().getName());

}[/JAVA]

This code will log each opened activity to google analytics.. Isn’t it easy? ๐Ÿ™‚

_trackEvent(String category, String action)

_trackEvent method is the same used on the web google analytics apis. I made this bridge because you should want to track some event made by the user.

Let suppouse you want to track a button click event on your user interface – this could help you understand how the user interact with your user interface – then you simply write the following statement on your View.OnClickListener implementation:

[JAVA] Button loginbutton=new Button();
loginbutton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
AnalyticsBridge._trackEvent(“Click”, “Login Button”);

}
});[/JAVA]

That code will track the event of category “Click” and action “login Button”.

Download:

Right now the library is quite stable . You can download it here

Thanks

Thanks to barakinflorida who corrected my bad english ๐Ÿ™‚

Vodafone Widget Android

17 Lug 09

vodafoneWidgetBitberzerkir sul forum di androidiani, e in seguito integrato con nuove funzionalitร  ( per ora ancora in beta ) da Andrea Baccega ( me ).

Il programma lo potete scaricare direttamente dal market e per ora suppora la visualizzazione di tre widges :

  • Infinity Sms
  • Traffico Resituo
  • Iphone DataPack

Vediamo un attimo piรน in dettaglio queste funzionalitร 

Infinity Sms

Il widget degli infinity sms per android รจ un widget rosso diviso in 3 righe:

  • Titolo : La dicitura “Infinity Sms”
  • Residuo : mosta gli sms inviati confronto al massimo inviabile giornalmente
  • Tempo : mostra l’ora di aggiornamento del widget

Questo widget รจ utilissimo per coloro che fanno un uso veramente massiccio degli sms, e quindi averlo sott’occhio puรฒ aiutarvi a non sforare la soglia giornaliera ๐Ÿ™‚

Read More

Cosa fare se Wp Super Cache non vuole andare

26 Giu 09

asdDa buon sviluppatore wordpress mi รจ capitato piรน e piรน volte di smanettare con blogs privati e business.

Tra i tanti problemi che ho affrontato e che ormai so risolvere a menadito c’รจ stato questo di un amico che non riusciva ad abilitare wp Super Cache..

Mi spiego meglio! Quest’amico aveva scaricato e correttamente configurato wp-super-cache che perรฒ non dava segni di vita alcuna.

Le pagine non venivano cachate e diciamo che era praticamente d’obbligo cacharle poichรจ il server sul quale il sito era hostato cominciava a tirare le cuoia.

L’amico, dopo avermi confessato che voleva mantenere la versione mobile del sito, aveva provato anche l’abilitazione di wp-cache che comunque non dava frutti e la cartella wp-content/cache/ era perennemente vuota ( a dire la veritร  veniva a crearsi una cartella in wp-content/cache/blogs ). Ecco quindi come ho proceduto fino all’individuazione dell’errore.

  1. Prova ad eliminare la cartella cache all’interno di wp-content e riabilitare wpCache. -> Risultato negativo.
  2. Prova a cambiare i permessi della cartella cache -> Risultato negativo
  3. Prova di debug e di forzature nel codice php di wp-super-cache -> Risultato Negativo
  4. Ho provato a cancellare i file wp-content/advanced-cache.php e wp-content/wp-cache-config.php -> Risultato negativo.
  5. Ho provato a forzare $use_flock in wp-cache-config.php -> Risultato negativo
  6. Ho provato a debuggare attraverso l’abilitazione in wp-cache-config.php -> Nessun Debug

Alla fine dopo tutti questi tentativi andati a male ho deciso di guardare la cosa piรน banale e piรน stupida.

Per abilitare il caching su wordpress si dovrebbe inserire la riga

define(‘WP_CACHE’, true);

all’interno del file wp-config.php nella root del vostro blog. Quindi guardo il file e vedo che la linea c’รจ ma l’occhio, che a volte รจ piรน astuto del cervello, intravede che qualcosa non va e quindi decido di leggermi riga per riga il file e cercare di dare una spiegazione alla sensazione che avevo appena avuto e infatti poco dopo mi accorgo che la precedente riga era subito dopo alla riga:

require_once(ABSPATH.’wp-settings.php’);

Non ho fatto altro che scambiare le righe e far diventare la parte finale del mio wp-config.php come segue:

define(‘WP_CACHE’, true);
require_once(ABSPATH.’wp-settings.php’);

Anzichรจ

require_once(ABSPATH.’wp-settings.php’);
define(‘WP_CACHE’, true);

Errore ovviamente di distrazione che perรฒ puรฒ portarvi a non capire il problema per diverse ore ๐Ÿ˜‰

Saluti! ๐Ÿ™‚

Come far funzionare thickbox e lightbox insieme

15 Apr 09

Ormai sempre piรน siti internet lavorano con effetti “speciali” tentando di far fare uno sbalzo al look & feel del proprio sito web castrando la staticitร  di ancora troppi siti web.

Navigando nel web ne trovi di tutti i colori, ma il primo รจ sicuramente lightbox. Alla sua nascita lightbox ha realmente rivoluzionato il modo di vedere le foto online.

Con l’andare nel tempo si รจ pensato bene di applicare l’effetto lightbox anche a contenuti diversi da immagini come html, form, video e qualsiasi altra cosa possibile.

Cosรฌ nacque thickbox che imparando dal suo fratello minore da la possibilitร  agli addetti ai lavori di aggiungere un tocco magico anche a video , thanks page e altro..

Purtroppo, alcuni di voi lo sapranno, i due sistemi non vanno molto d’accordo e infatti la maggior parte delle volte ci ritroviamo difronte a un sito dove funziona o lightbox o thickbox. Ma perchรจ?

Lightbox e Thickbox sono state sviluppate con due tecnologie differenti, talmente differenti che sotto sotto sono simili tanto da andare in conflitto con un risultato impredicibile :).

Per fortuna la soluzione c’รจ e non รจ nemmeno cosรฌ di difficile implementazione. Infatti vi basterร  modificare il file thickbox.js nel seguente modo:

  • inserisci all’inizio del file la stringa jQuery.noConflict();
  • effettua un cerca e rimpiazza Con i seguenti parametri –> cerca: $( , rimpiazza: jQuery(
  • effettua un altro cerca e rimpiazza con i seguenti parametri –> cerca: $. , rimpiazza: jQuery.

Se non si capisse , l’ultimo parametro del cerca รจ [Dollaro][Punto] ..

Ad ogni modo, per i pigri vi lascio in allegato il file thickbox.js versione 3.1 ๐Ÿ™‚

Saluti a tutti,

Andrea Baccega