Wednesday, November 7, 2012

How to disable USB storage mode on Android

If you are annoyed with the continuous popup of the SD card and the phone internal storage on your computer each time you connect your Android phone to the system, here is how you can disable it.

Once you connect your phone to the system and this happens, you'll notice a small USB icon at the top of the phone screen. Drag the top bar down and you'll find an option on the top that says, "USB connection Select to manage your USB connection."

Once you click (tap) on that, you can select the mode you want. To disable storage mode, select "Charge only". To enable, select USB Mass storage.

Your phone should remember the mode you selected last time.

Wednesday, August 31, 2011

Bash: copy directory structure without the files

Here's a one-liner to do that. Go to the source directory and say

user@host:source$ find * -type d -exec mkdir destination/\{\} \;

Tuesday, August 9, 2011

Changing display resolution on Ubuntu when the resolution option doesn't show up

It is very annoying when you have a good monitor (an NEC MultiSync LCD1970NX in my case), capable of supporting 1280x1024 or some such high resolution, whereas Ubuntu simply cannot see beyond 832x624.

Earlier versions of Ubuntu had the xorg.conf file which is no longer present, although if you craft it by hand it is still going to be used. That seems like a dangerous proposition, though - a simple mistake could screw up at least something that is working.

I found the savior in the command xrandr, thanks to X/Config/Resolution page on the ubuntu wiki. And here is what I have done so far:

1. I first ran the command xrandr to make sure that the VGA1 indeed existed. As it turns out, that command can also tell you what is the highest resolution your monitor can support:
sudipta@Springfield:~$ xrandr
Screen 0: minimum 320 x 200, current 832 x 624, maximum 4096 x 4096
VGA1 connected 832x624+0+0 (normal left inverted right x axis y axis) 376mm x 301mm
   1280x1024      60.0 +   75.0 
   1280x960       60.0 
   1152x864       75.0 
   1024x768       75.1     70.1     60.0 
   832x624        74.6*
   800x600        72.2     75.0     60.3     56.2 
   640x480        72.8     75.0     66.7     60.0 
   720x400        70.1 
LVDS1 connected 832x624+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1280x720       60.0 +
   832x624        74.6*
   800x600        85.1     72.2     75.0     60.3     56.2 
   640x480        85.0     72.8     75.0     59.9 
   720x400        85.0 
   640x400        85.1 
   640x350        85.1 
See that 1280x1024 at the top of the list? That is how high my monitor could go. And see that line in the middle with a * at the end (832x624        74.6* in my case) - that one is what I am currently running. And strangely enough, although xrandr knew the highest possible on available, the monitor options only showed 832x624 to be the highest:

So all I had to do to rectify the situation was to open up the gnome terminal and run
xrandr --output VGA1 --mode 1280x1024
which was the highest one supported by my monitor, as mentioned above. Note that I did not specify a refresh rate (using --rate 75 or 60): I let the computer decide for itself. And voila! I had a 1280x1024 screen on my monitor!

I will post an update about how to make the change permanent as well, although the wiki already mentions some options.

Thursday, July 7, 2011

ln -sf gives ?[01;32mFILENAME?[0m

So I was trying to link to a few files from a script and it kept getting me these strange links instead of the actual file name. This is what I had in my shell prompt:

for i in `ls /var/www | grep FILENAME`; do ln -sf $i .; done

[The grep is there because of multiple files which began by the same name]. But then what I got instead in the folder where I was running this script was this:

sudipta@Hogwarts:~/html$ ls -l
total 156
lrwxrwxrwx 1 sudipta sudipta     25 2011-07-06 23:08 ?[01;32mFILENAME?[0m -> ?[01;32mFILENAME?[0m

lrwxrwxrwx 1 sudipta sudipta     34 2011-07-06 23:08 FILENAME.txt -> FILENAME.txt

I had no idea where this strange file was from or why it was here. Also, only a few files were getting affected by this. A simple "ls -l" showed that this was happening only to those files which had the executable file set

After some time, I realized that this was a permissions problem. I gave the local directory write permission by www-data, and then sudo-ed myself into www-data and re-executed my script again.

sudipta@dev:~/html$ rm -f FILENAME*sudipta@dev:~/html$ chmod a+w .
sudipta@dev:~/html$ sudo su www-data
[sudo] password for sudipta:
$
for i in `ls /var/www | grep FILENAME`; do ln -sf $i .; done
$^D
And that did it! All I needed was to run the thing as www-data with write permission in my current directory.
sudipta@Hogwarts:~/html$ ls -l
total 156
lrwxrwxrwx 1 sudipta sudipta     25 2011-07-06 23:08 FILENAME -> FILENAME

lrwxrwxrwx 1 sudipta sudipta     34 2011-07-06 23:08 FILENAME.txt -> FILENAME.txt

Monday, February 14, 2011

Deleting all panels on GNOME desktop

Apparently, deleting all panels is not the easiest thing to do on a GNOME desktop.

Open gconf-editor and goto /apps/panel/toplevels and set these values:
auto_hide: yes


auto_hide_size: 1
expand: no
hide_delay: 1
monitor: 3
unhide_delay: 10000
x: 10000
y: 10000

This will hide the panel permanently.

Friday, November 19, 2010

Keynote like multi-screen output in linux

I normally create my presentations using the beamer package in Latex compiling them into pdf, can't really imagine why would anyone use anything else. I use evince to display the pdf on a projector, but found it to be relatively basic.

I was looking for an application to display some meta-information like the remaining time and the preview of the next slide on my laptop while displaying the current slide on the projector, the way Keynote does it. I found the pdf_presenter_console application, it is fairly minimalistic but seems to do the trick for me.

Tuesday, November 9, 2010

PHP Fatal error: Class 'PDO' not found

When using SQLite with Php for the first time, you might get this error under /var/log/httpd/error_log (I was using a Fedora 13 machine). The trick is to install a package called "php-pdo" and then use the function.

su
yum install php-pdo

Hopefully it will save someone some heartache :)