Categorie
Informatica

Regole inflessione CakePHP in italiano / Italian CakePHP inflector rules

Regole per l’italiano da aggiungere all’inflector di CakePHP. Possono essere aggiunte alla fine del file bootstrap.php [sono un’esempio, poi è possibile estenderle con altri casi particolari]:

//
// I N F L E C T O R
//
/*
Inflector::rules('transliteration', array('/å/' => 'aa'));
*/
Inflector::rules('plural', array(
 'rules' => array(
 '/^(.*)io$/i' => '\1i',
 '/^(.*)o$/i' => '\1i',
 '/^(.*)a$/i' => '\1e',
 ),
 //'uninflected' => array('dontinflectme'),
 'irregular' => array(
 'mare' => 'mari',
 'dito' => 'dita'
 )
));
Inflector::rules('singular', array(
 'rules' => array(
 '/^(.*)tari$/i' => '\1tario',
 '/^(.*)i$/i' => '\1o',
 '/^(.*)e$/i' => '\1a',
 ),
 //'uninflected' => array('dontinflectme'),
 'irregular' => array(
 'mari' => 'mare',
 'dita' => 'dito'
 )
));
Categorie
Informatica Information and Communications Technology

Windows Vista CMD slow startup / Windows Vista, avvio lento della CMD

Using Windows Vista, running cmd, makes it hangs for some seconds and then start.
I solved the issue removing any additional keyboards layouts from:
“System Settings->Region and Language options->Keyboards & Languages->Change keyboards”
see http://serverfault.com/questions/26217/win7-command-processor-cmd-exe-really-slow/210961#210961
[ITA]In Windows Vista ho notato un rallentamento dell’avvio della console (CMD). Lasciando un solo layout di tastiera il problema si è risolto

Categorie
Information and Communications Technology

Godex EZ-DT-2 EZ-DT-4 Thermal Label Printer left and right hooks alternative solution

[CHIUSURA ALTERNATIVA PER GODEX EZ-DT-2 E EZ-DT-4]
Replaces spare parts number 700-057200-011 (right hook) and 700-057300-011 (left hook)
Sostituzione ricambi 700-057200-011 (leva destra) e 700-057300-011 (leva sinistra)
Godex EZ-DT-2 Right Hook Godex EZ-DT-2 Left Hook

Categorie
Informatica Operatori Telefonici

Traffico Tethering Router WiFi nascosto tramite proxy socks su Android

L’articolo è stato aggiornato. La nuova versione si trova a questo link:
Traffico Tethering Router WiFi nascosto tramite proxy socks su Android

Categorie
Information and Communications Technology

Windows Vista and Windows 7 Common Cleanup Operations Checklist

In this post i will write a checklist of common operations i do after clean installation of Windows Vista or Windows 7 (the most are not recommeded by Bill):
1. disable UAC (User Account Control)
2. disable System Protection on all disks
3. delete all Tasks except Registry Backup Task

Delete all folders contained in:
C:\Windows\system32\Tasks [for 32 and 64 bit systems] (do not delete the folder Microsoft\Windows\Registry it’s the registry backup, it’s important to recover a corrupted registry)
C:\Windows\SysWOW64\Tasks [for 64 bit only]

4. [OPTIONAL] disable Task Scheduler Service (doing this genarates an error when installing Office 2016)

It cannot be disabled with services.msc, but only via registry: locate HKLM\SYSTEM\CurrentControlSet\Services\Schedule and change the Start value from 2 to 4

5. disable Windows Search / Indexing

Control Panel >> Programs and Features >> Turn Windows features on and off and uncheck Windows Search

6. disable Automatic Defragmentation Service

Run services.msc and disable “Disk Defragmenter” service

7. cleanup msconfig
8. enable telnet client

Control Panel >> Programs and Features >> Turn Windows features on and off and check telnet client

Categorie
Information and Communications Technology

Windows 7 freezes after being idle for a while [SOLVED]

Today i solved a two year problem with Windows 7 and my hp notebook. After leaving the computer idle for a while 10 or 20 minutes or more, the computer become unresponsive and the hard disk keeps working forever. To restore to normal operation i had to reset the pc.
To solve the problem i followed these steps:
1. Disable Windows Search from Control Panel >> Programs and Features >> Turn Windows features on and off and uncheck Windows Search
2. Remove all Windows Tasks, deleting all files and folders in these folders:
C:\Windows\system32\Tasks [for 32 and 64 bit systems]
C:\Windows\SysWOW64\Tasks [for 64 bit only]
3. Disable Windows Task Scheduler from registry: locate HKLM\SYSTEM\CurrentControlSet\Services\Schedule and change the Start value from 2 to 4
4. Disable Disk Defragmenter service from services.msc, set as DISABLED
5. reboot

Categorie
Information and Communications Technology

How to hide fields in CakePHP 2.0 scaffolding views

This is a simple code to hide fields in scaffolding views. In the controller add the method beforeRender in this way:

    public function beforeRender() {
        $action = $this->request->params['action'];
        
        if ($action == 'index') {
            $fields =  array('id', 'username', 'role', 'created', 'email'); //'password','modified'
            $this->set('scaffoldFields', $fields);
        } else if ($action == 'view') {
            $fields =  array('id', 'username', 'role', 'created', 'modified', 'email'); //'password'
            $this->set('scaffoldFields', $fields);
        }
        
        return parent::beforeRender();
    }

in this example the fields were changed in the index and view actions, but in the other actions the fields are displayed all.
 

Categorie
Information and Communications Technology

Android 4: Start Contacts Application / People Application on tablet when missing icon

I have a tablet (allwinner a13 mid tablet 7″). Contacts application Contacts.apk is installed, but the icon is missing in the application list.
It can be started from terminal emulator. My android version is 4.0.4, i run on the terminal this command:

am start -n com.android.contacts/com.android.contacts.activities.PeopleActivity

or

am start -n com.android.contacts/.activities.PeopleActivity

[see: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.4_r2.1/com/android/contacts/activities/PeopleActivity.java?av=f]
 

Categorie
Information and Communications Technology

Windows Vista, Windows 7 delete all scheduled tasks and folders

  1. Run Cmd as Administrator
  2. Execute this command: schtasks /delete /tn *

This delete all tasks, but not the folders. To delete also the folders you must delete those in these directories:

  • C:\Windows\System32\Tasks\Microsoft\Windows
  • C:\Windows\SysWOW64\Tasks\Microsoft\Windows
Categorie
Information and Communications Technology

Programmatically create contacts on Android 1.6 Donut (API Level 4) targetting HTC Tattoo

Here is the code i used:

    private void addPeople(String name, List<String> homeNumbers, List<String> mobileNumbers) {
        //insert contact
        ContentValues peopleContentValues = new ContentValues();
        peopleContentValues.put(Contacts.People.NAME, name);
        //WARNING: this is for HTC to indicate the contact type
        //extra_group = 0 [google contact]
        //extra_group = 1 [??: maybe SIM contact]
        //extra_group = 2 [phone concact]
        peopleContentValues.put("extra_group", 2);
        Uri peopleUri = getContentResolver().insert(Contacts.People.CONTENT_URI, peopleContentValues);
        
        //get contact id [i need it to add phone numbers to it]
        Cursor cursorPeople = getContentResolver().query(peopleUri, new String[]{Contacts.People._ID}, null, null, null);
        cursorPeople.moveToNext();
        long peopleId = cursorPeople.getLong(0);
        
        //add phones
        for (String num : mobileNumbers) {
            addPhoneToPeople(peopleId, Contacts.Phones.TYPE_MOBILE, num);    
        }
        for (String num : homeNumbers) {
            addPhoneToPeople(peopleId, Contacts.Phones.TYPE_HOME, num);    
        }
    }
    
    private void addPhoneToPeople(long peopleId, int type, String number) {
        if (number != null && !number.equals("")) {
            ContentValues phoneContentValues = new ContentValues();
            phoneContentValues.put(Contacts.Phones.PERSON_ID, peopleId);
            phoneContentValues.put(Contacts.Phones.TYPE, type);
            phoneContentValues.put(Contacts.Phones.NUMBER, number);
            getContentResolver().insert(Contacts.Phones.CONTENT_URI, phoneContentValues);
        }
    }