Thursday 24 May 2012

[Git] Clone the local repositor

You can clone your local repositor somewhere without any authentication, just find out what is your path of the repo.

git clone --no-hardlinks <repo path>

[Git] Restore file or directory

Git has a great system to restore a file that you maybe deleted, you can check what is the last commit about the file/directory:

git rev-list -n 1 HEAD -- <file_path>
If you want to restore it you can use this simple command and in a few seconds your file/directory will be back

git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"

Friday 11 May 2012

Android: Force gallery refresh

This is a simple broadcast to force the gallery refresh instead of wait that you plug a usb cable or remount the sdcard:


 sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+
                     Environment.getExternalStorageDirectory())));
Basically  the code does a fake action and the gallery will update the pictures.

Friday 4 May 2012

Convert a String to an Integer

I think that a lot of people is looking for a function to convert a string to an integer because the function ATOI works only with char. 

This is the solution for you project with Arduino:
int stringToNumber(String thisString) {
int i, value, length;
length = thisString.length();
char blah[(length+1)];
for(i=0; i<length; i++) {
blah[i] = thisString.charAt(i);
}
blah[i]=0;
value = atoi(blah);
return value;
}