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);
        }
    }

 
 

Categorie
Information and Communications Technology

VBA Macro Example to Update Outlook Contacts

This is a simple macro example that describes how to update outlook contacts:

Sub updateContacts()
    Dim ContactsFolder As Folder
    Dim Contact As ContactItem
    Set ContactsFolder = Session.GetDefaultFolder(olFolderContacts)
    i = 0
    For Each Contact In ContactsFolder.Items
        first_name = Contact.FirstName
        middle_name = Contact.MiddleName
        last_name = Contact.LastName
        If middle_name <> "" Then
            Contact.FirstName = first_name & " " & middle_name
            Contact.MiddleName = ""
            Contact.Save
            i = i + 1
        End If
    Next
    MsgBox ("Contacts Found: " & ContactsFolder.Items.Count & ", Updated: " & i)
End Sub
Categorie
Information and Communications Technology

GNU ddrescue log SVG graph

This is a perl script that creates the svg code that matches a ddrescue log file.
SVG module is required. Edit the $INPUT_FILE and $SCALE_FACTOR variables as needed.
The SVG code is outputted to standard output. The messages to standard error.
Use ddrescue-svg-log.pl > output.svg to output to file.

#!/usr/bin/perl
use strict;
use warnings;
use SVG;
use Math::BigInt;
##############################
my $SCALE_FACTOR = 10240000;
my $SCALE_FACTOR_LABEL = 1024 * 1024 * 1024; #giga
my $INPUT_FILE = "sda-80gb-log.txt";
##############################
my $ddlogfile;
open $ddlogfile, "<$INPUT_FILE";
my $svg = SVG->new(width=>1000,height=>200);
# use explicit element constructor to generate a group element
my $svg_disc_group=$svg->group(id => 'disc_group');
while (<$ddlogfile>) {
    my $row = $_;
    chomp $row;
    # STATUS CHARACTERS: +,-,/,*,?
    if($row =~ m/^(0x[0-9A-z]*)\s*(0x[0-9A-z]*)\s*(\+|-|\/|\*|\?)/) {
        my $start = $1;
        my $size = $2;
        my $status = $3;
        
        print STDERR $row;
        
        #CALCULATE SVG COORDINATES USING $SCALE_FACTOR
        my $bigint_start_scaled = Math::BigInt->new($1);
        my $bigint_size_scaled = Math::BigInt->new($2);
        my ($_qx, $_rx) = $bigint_start_scaled->bdiv($SCALE_FACTOR);
        my ($_qw, $_rw) = $bigint_size_scaled->bdiv($SCALE_FACTOR);
        my $x = $_qx->numify() + ( $_rx->numify() / $SCALE_FACTOR ) ;
        my $w = $_qw->numify() + ( $_rw->numify() / $SCALE_FACTOR ) ;
       
        #LABEL VALUES
        my $bigint_start_label = Math::BigInt->new($1);
        my $bigint_size_label = Math::BigInt->new($2);
        my ($_q_start_lbl, $_r_start_lbl) = $bigint_start_label->bdiv($SCALE_FACTOR_LABEL);
        my ($_q_size_lbl, $_r_size_lbl) = $bigint_size_label->bdiv($SCALE_FACTOR_LABEL);
        my $start_lbl = $_q_start_lbl->numify() + ( $_r_start_lbl->numify() / $SCALE_FACTOR_LABEL ) ;
        my $size_lbl = $_q_size_lbl->numify() + ( $_r_size_lbl->numify() / $SCALE_FACTOR_LABEL ) ;
        my $rect_label = sprintf("%.2f", $start_lbl) . "[" . sprintf("%.2f", $size_lbl) . "]($status)";
               
        my $svg_sector_group = $svg_disc_group->group();
        my $rect_style = ($status eq '+')?{ fill=>"green" }:{ fill=>"red", stroke=>"red" };
        
        # add a rectangle to the group
        $svg_sector_group->rectangle(
                x     => $x,
                width => $w,
                y => 0,
                height => 30,
                style => $rect_style
            );
               
        $svg_sector_group->text(x=>$x, y=>40, -cdata=> $rect_label, style=>'font-size: 2px');
        
        print STDERR ("START: $start, SIZE: $size, STATUS: $status\n");
    }
    
}
# now render the SVG object, implicitly use svg namespace
print $svg->xmlify;
Categorie
Information and Communications Technology

Yii Console Log with Unit Testing

1. install phpunit correctly
pear install phpunit/PHPUnit
pear install phpunit/PHPUnit_Selenium
2. create the class CConsoleLogRoute in the components directory in the file CConsoleLogRoute.php with this code:
<?php
class CConsoleLogRoute extends CLogRoute {
protected function processLogs($logs)
{
foreach($logs as $log) {
echo $this->formatLogMessage($log[0],$log[1],$log[2],$log[3]);
}
}
}
3. configure YII to log when unit testing:
3a. add the log key in the components array in protected/config/test.php
‘log’=>array(
‘class’=>’CLogRouter’,
‘routes’=>array(
array(
‘class’=>’CConsoleLogRoute’,
‘levels’=>’error, warning, info, trace’,
),
),
),
3b. add some lines in protected/tests/bootstrap.php, the modified file should be this: (added the lines with YII_DEBUG, YII_TRACE_LEVEL, autoFlush and autoDump)
<?php
// change the following paths if necessary
$yiit=dirname(__FILE__).’/../../../framework/yiit.php’;
$config=dirname(__FILE__).’/../config/test.php’;
defined(‘YII_DEBUG’) or define(‘YII_DEBUG’,true);
defined(‘YII_TRACE_LEVEL’) or define(‘YII_TRACE_LEVEL’, 0);
require_once($yiit);
require_once(dirname(__FILE__).’/WebTestCase.php’);
Yii::createWebApplication($config);
Yii::getLogger()->autoFlush = 1;
Yii::getLogger()->autoDump = true;

Categorie
Information and Communications Technology

Virtual Burners for HP Recovery Manager Media Creator ISO creation

With my new laptop i want to create the recovery discs into the iso format, without burning any real dvd.
Then i searched for a virtual dvd-r dvd-rw burner. I found TotalMounter 1.50 (free software). Then i created a virtual empty disc (a .iso file on the filesystem) and used HP Recovery Media Creator to burn to the dvd. This do not work, HP Recovery Media Creator gave me an error: REWRITEABLE MEDIA NOT SUPPORTED. TotalMounter mounted a virtual DVD-RW disc. And no option on TotalMounter to choose from DVD-R or DVD-RW to insert into the virtual burner.
Then i found Phantom Drive. That was the solution. Phantom Drive is another virtual burner software. It let me choose the type of virtual media: DVD-R, DVD+R, DVD-RW, and so on.
So first of all open Phantom Drive Starter and choose Phantom Settings. Uncheck the option:
“Reinsert image after burning if ejected
Then start the HP Recovery Media Creation process. When it asks for a blank dvd-r, go again to the Phanthom Drive Starter and choose Phantom Creator. Choose “DVD-R” as media type, then check “Create an iso image” and then choose the file location for the iso image, for example for the first DVD-R choose C:\Users\…\recovery_dvd1.phi (the phi extension will be replaced automatically with the iso extension because we choosed Create an iso image).
HP Recovery will recognize and use this virtual DVD-R.
Then when HP Recovery Media Creator ends burning (virtually) the first (virtual) DVD-R, it will ask you for the second blank DVD-R. Again use the Phantom Creator and change only the file location to another name recovery_dvd2.phi for example.
And so on for the other DVDs.
I think this method could be used for every media recovery creator as that from Acer, Asus and others. Thanks to Phantom Drive, great piece of software!!

Categorie
Information and Communications Technology

SanDisk Cruzer Blade Windows Icons

I created some .ico files for Cruzer Blade Flash Drive:

Cruzer Blade Icon
Cruzer Blade Straight Icon
Sandisk Icon