четвъртък, 30 декември 2010 г.

How to install android apps without market

Ok, I have a new phone SE X8, because my LG Arena is being repaired (hopefully). This one has Android OS. First - I struggled to update Android trough Wine and in the end, I needed to use my virtual windows to do so. And it was very annoying, because I needed to manually load the usb from the top menu of the machine. Very stupid. Anyway, now it's updated.
My next problem was how to install anything without a Google account. Of course, I have Gmail account, it's not the point. My problem is that I don't see ANY reason to connect my gmail account with my phone, since phones are easily lost or stolen and I really don't want my gmail account falling into wrong hands. Not that I have very sensitive information in it, I try to delete such stuff immediately. But still, this is my default email and I really don't want it jeopardized.
My other problem is that your license agreement with Android market involves agreement that Google has the right to REMOVE any application from YOUR phone that it finds bad for you. In any way. That's obviously wrong and I would never agree to this provided I have the choice.
Well, it turned out that I actually have that choice.
So to install apps without Market:
0. From your phone settings menu, choose "Applications" -> Unknown sources (allow apps which are not from Market) -> Allow. (source)
1. Find sites with apps you can download without barcodes or other Google shit. Good start is: androidfreeware.org and http://google-androids.ru or http://www.brothersoft.com/mobile and http://getandroidstuff.com/ 
2. Download whatever you like. Remember that those apps were not checked by the careful eye of Google, so do it with caution and check comments and so on to be sure the app is safe. And don't download anything connected with financial stuff.
3. Now that you have all the apps, you need an android file manager to install them on you phone. How to install it without market? Easily!
4. Connect your phone to Internet using wireless or gprs or 3g or whatever.
5. Open default browser, type one of the urls above and download a file manager. When the download is complete, click/tap over the file (in the download window) and it will ask you whether to install. Say YEAH and now you have a file manager.
6. Use your newly installed file manager to install all the other apps that you transfered to a folder on your phone using USB cable (or bluetooth).
7. You can avoid the use of computer if you're a fan of browsing trough your phone - simply connect to wireless (or cheap net) and browse trough those sites with your default browser. Download whatever you like and when the download is complete choose "install". And that's it.
Now you can download and install whatever you like without the annoying interference of Market. Just don't forget that apps on Market are generally safer than other sources. And if you "root" your phone, Google probably won't be able to remove your apps. But I really don't want to give my gmail account so I prefer to do it this way.
As to my X8, I actually like it, except for the lousy camera without flash, but otherwise, it's quite nice phone.

четвъртък, 23 декември 2010 г.

Script to find and replace text in multiples files

Ok, I wanted to find a way to edit multiple files (mostly html files) for my site, finding and replacing certain text in them. Here's my progress so far. Please, don't laugh at my efforts, I'm not a bash programmer, I know how to do basic stuff, but this is not my job, not even my hobby. So, if there is simpler and more obvious way - just let me know.
I used following resources: site 1 and site 2 to produce following script: 

#!/bin/bash
     for fl in *.txt; do
     mv $fl $fl.old
     sed "s/$1/$2/g" $fl.old > $fl
     rm -f $fl.old
     done

What it does is to look for a certain string $1 in all the txt files in the directory and to replace it with $2, where you start the script with
sh name.sh $1 $2
where you put the strings $1 and $2 in ' '.
It works beautifully and replaces the strings as it's supposed to. My major
problem with it is that the strings aren't supposed to include "/" in them. Which when you edit an html file is bad. If you want to use that character, you need to "escape" it with "\" meaning that '</div>' will have to become '<\/div>'. I wanted to make a script that will do that automatically, but so far without success. But still, you can easily replace a line with other one or two using this script. And that was the point so. Cheers.
P.S. For more useful info on "sed" look here.

неделя, 19 декември 2010 г.

How to use Alcatel One Touch X220L 3G modem in Linux

Thanks to the many and extremely unnerving problems with my Internet connection, we decided to get a 3G/HSPA USB modem, for backup. Of course, all the installation files are for Windows, so I had to Google for a solution. I found this Ubuntu HOWTO that helped me connect to Internet with the USB device.
Without getting in details, here's what I did:
Plug-in your device and type:
>$sudo lsusb
Look for a line looking like this:
>$Bus 001 Device 003: ID 1bbb:f000 T & A Mobile Phones

If you have "f000" part, then you need to install a program that will switch it to "0000".
1. Install usb_modeswitch. Sabayon Linux had it in Entropy, but you may need to download it.
2. Configure usb_modeswitch ( >$sudo nano /etc/usb_modeswitch.conf ) adding the lines:
########################################################
# Alcatel X220L

DefaultVendor=  0x1bbb
DefaultProduct= 0xf000

TargetVendor=   0x1bbb
TargetProduct=  0x0000

# only for reference
# MessageEndpoint=0x01

MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
########################################################

Save and plug the device again.
3. >$sudo usb_modeswitch


4. Look at your syslog ($dmesg|tail), you should now see:
"..... Direct-Access USBModem MMC Storage 2.31 PQ: 0 ANSI: 2 "

5. Start the driver for the modem
>$sudo modprobe usbserial vendor=0x1bbb product=0x0000

In >$dmesg|tail you should now see:

Jul 11 10:24:16 eee-yard kernel: [  100.388222] usb 1-2: configuration #1 chosen from 1 choice
Jul 11 10:24:16 eee-yard kernel: [  100.390492] usbserial_generic 1-2:1.0: generic converter detected
Jul 11 10:24:16 eee-yard kernel: [  100.390658] usb 1-2: generic converter now attached to ttyUSB0
Jul 11 10:24:16 eee-yard kernel: [  100.390952] usbserial_generic 1-2:1.1: generic converter detected
Jul 11 10:24:16 eee-yard kernel: [  100.391068] usb 1-2: generic converter now attached to ttyUSB1
Jul 11 10:24:16 eee-yard kernel: [  100.394230] scsi4 : SCSI emulation for USB Mass Storage devices
Jul 11 10:24:16 eee-yard kernel: [  100.395689] usbserial_generic 1-2:1.3: generic converter detected
Jul 11 10:24:16 eee-yard kernel: [  100.395847] usb 1-2: generic converter now attached to ttyUSB2
Note the last number where your usb puts the modem, in my case, it was USB4.
To check it, just enter:
>$screen /dev/ttyUSB4

and at the prompt, ask the modem to identify itself typing:
>ATI
The answer should be:
>Manufacturer: TCT Mobile International Limited
Model: HSPA Data Card
Revision: C1111000
IMEI: 352079030611766
+GCAP: +CGSM,+DS,+ES


If you want to automate this, you can add the rules with >$sudo nano /etc/udev/rules.d/50-alcatel.rules adding

SUBSYSTEM=="usb", SYSFS{idProduct}=="f000", SYSFS{idVendor}=="1bbb", RUN+="/usr/sbin/usb_modeswitch"
SUBSYSTEM=="usb", SYSFS{idProduct}=="0000", SYSFS{idVendor}=="1bbb", RUN+="/sbin/modprobe usbserial vendor=0x1bbb product=0x0000"

Check where usb_modeswitch is, mine was in "/usr/sbin", but if it's not there, use the appropriate directory.

Connecting the modem with wvdial:

1- Remove the PIN of your SIM

2- >sudo wvdial

But first,
>$sudo gedit /etc/wvdial.conf - here is my file, which works with VIVACOM Bulgaria, for TIM Italy, check the source.

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","internet.vivacom.bg"
Modem = /dev/ttyUSB4
Check Def Route = on
Phone = *99#
Username = VIVACOM
Password = VIVACOM
Modem Type = Analog Modem
Stupid Mode = 1
Baud = 460800
New PPPD = yes
ISDN = 0
AutoDNS = 1

You should change init3 and User and Password with those given by your providers.

Once you created the file, just run wvdial (or in my case, >$sudo wvdial...) and that's it. You'll receive some messages but after you see you DNS, everything is ready for browsing!
Enjoy!

сряда, 15 декември 2010 г.

HOWTO change your File Associations

Ok, since I installed Calibre, I have serious problem with files I opened with kwrite, which now Calibre decides to be eBooks and tries to open them and add them to its database. That's obviously extremely annoying when all you want is to open your text file and edit it.
With simple associations like text files, I dealt easily clicking with the right button the txt files and telling KDE that I want kwrite to be my default application. Same happened also for .tex files. So these are fixed.
I have serious problem with .job files and .mw files which sometimes KDE remembers to open with kwrite, but sometimes doesn't. So I needed to find where KDE(and Linux as a whole) stores its file associations and to change them. Here's what I found.
1.) /usr/share/applications/defaults.list
-- I didn't have that file, but you can see all of your .desktop files in the directory.
2.) /usr/share/applications/mimeinfo.cache
-- Here you can find all the file associations and this is the file you must edit.
3.) ~/.local/share/applications/mimeapps.list
-- Not complete list of the associations, you might want to check/edit that file too, just to make sure everything is correct.


Edit the files:
$ sudo gedit /usr/share/applications/defaults.list
or if you like me don't have the above file:
$ sudo gedit /usr/share/applications/mimeinfo.cache
and also
$ gedit ~/.local/share/applications/mimeapps.list
Find the place that interests you, in my case any mentioning of Calibre. Find those lines (with ctrl+f) and then reorder the applications:
For example:
text/plain=calibre-ebook-viewer.desktop;calibre-gui.desktop;writer.desktop;kde4-kwrite.desktop;
should become:
text/plain=writer.desktop;kde4-kwrite.desktop;calibre-ebook-viewer.desktop;calibre-gui.desktop;
Just make sure, the application you want to open that file type is the first in the row. If you want to add application that you don't see in the row, look for its name in " /usr/share/applications/" (it will be something.desktop) and write that name.
Do that on all the places where your application occur in the file or to all file types you want to reorder.
Save and exit. Don't forget that after each application in the row, you need to put semi-colon! And also in the end of each line!
"Step 4:
Final step, and yes it's easy :-). All you have to do now is make your changes final. I have yet to find another...simply just logout then back in to see the fantastic changes." (source)


Enjoy!

петък, 3 декември 2010 г.

How to enable tapping on Synaptic Touchpads

Today I discovered I cannot tap on my touchpad. Don't ask how come I didn't realist that earlier, I just didn't.
So, here's the solution as suggested by Sabayon Wiki. It's in Italian, for unknown reasons.
So, it turns out, you need to add few lines to /etc/X11/xorg.conf
Before you proceed, make a backup of xorg.conf, because we all know how easy it is to mess things up.
So
sudo cp xorg.conf xorg.conf.bck
sudo nano xorg.conf
After the end of your Device section, paste the following new section:

Section "InputDevice"
        Identifier "Synaptics Touchpad"
        Driver "synaptics"
        Option "AlwaysCore" "true" # send events to CorePointer
        #Option "Device" "/dev/input/mice"
        Option "Device" "/dev/psaux"
        Option "Protocol" "auto-dev"
        Option "SHMConfig" "false" # configurable at runtime? security risk
        Option "LeftEdge" "1700" # x coord left
        Option "RightEdge" "5300" # x coord right
        Option "TopEdge" "1700" # y coord top
        Option "BottomEdge" "4200" # y coord bottom
        Option "FingerLow" "25" # pressure below this level triggers release
        Option "FingerHigh" "30" # pressure above this level triggers touch
        Option "MaxTapTime" "180" # max time in ms for detecting tap
        Option "VertEdgeScroll" "true" # enable vertical scroll zone
        Option "HorizEdgeScroll" "true" # enable horizontal scroll zone
        Option "CornerCoasting" "true" # enable continuous scroll with finger in corner
        Option "CoastingSpeed" "0.30" # corner coasting speed
        Option "VertScrollDelta" "100" # edge-to-edge scroll distance of the vertical scroll
        Option "HorizScrollDelta" "100" # edge-to-edge scroll distance of the horizontal scroll
        Option "MinSpeed" "0.75" # speed factor for low pointer movement
        Option "MaxSpeed" "4.50" # maximum speed factor for fast pointer movement
        Option "AccelFactor" "0.0020" # acceleration factor for normal pointer movements
        Option "VertTwoFingerScroll" "true" # vertical scroll anywhere with two fingers
        Option "HorizTwoFingerScroll" "true" # horizontal scroll anywhere with two fingers
        Option "EmulateTwoFingerMinZ" "120" # this may vary between different machines
        Option "TapButton1" "1"
        Option "TapButton2" "2"
        Option "TapButton3" "3"
EndSection


Also, add in the section ServerLayout a line, so that it becomes:
Section "ServerLayout"
        ...
        ...
        InputDevice "Synaptics Touchpad" "SendCoreEvents"
EndSection


Save (ctrl+o) and exit (ctrl+x).
You'll need to restart xorg.conf in order for the changes to take effect. To do that use your favorite way to restart X or simply Reboot. If something's not working, just use your old xorg.conf. Also, take a look in the example xorg.conf in the source page to make sure that you pasted the lines on the right place.

неделя, 28 ноември 2010 г.

How to run Dolphin as root?

Ok, I had this ridiculous problem today. I wanted to run Dolphin as root and I typed "sudo dolphin". Didn't work. I typed "su" and then "dolphin". Again to no avail. So little googling told me that I'm doing it wrongly.

"kdesu dolphin"

is the command. And it works :)
Maybe I'm just very unexperienced, but I think that last time I typed "sudo dolphin" it actually worked. Don't know why that changed.

сряда, 17 ноември 2010 г.

How to minimize Firefox memory usage

I don't know for what reason, but on my computer, Firefox tends to eat a lot of memory. And I mean A LOT. Like between 900MB and ~2GB. And I have 4GB in total, so obviously, that sucks.
So, I Googled a little and found a solution that so far works for me.
The tutorial found on this site has 2 parts, but on Linux, I think that only the second one works. So. Do:
1. In the address bar type: about:config
2. Search  browser.cache.disk.capacity in the filter.
3. Change the value so that it corresponds to your machine. The values are as follow:
"20000 is recommendable you have between 512Mb and 1GB of Ram. If you have less than 512Mb then reduce to 10000. Default is 50000, max is 51200. source"
Mine was set to 512000, but that didn't stop Mozilla from taking whatever I have. So now I set it to 20000 and so far everything works great.
Good luck!

понеделник, 15 ноември 2010 г.

Make Sony Reader PRS 600 show cyrillic

Hello all. Today, I got my new Reader. It's very, very cute and lovely and I'm very happy with it. It reads fine (even if the contrast is less than on the new PRS 650 or Kinddle - but then, they are more expensive or unavailable in Bulgaria). So PRS 600 it is.
For now, it behaves very nicely and I even made few drawings just for the fun of drawing on the screen. I also downloaded free books from http://www.epubbooks.com/ and some Bulgarian sites and putting them on the Reader is piece of cake. I also tried reading scientific pdf - the text is really somewhat small in the original size and looks weird when you zoom in, but the figures look cool and hey, that's the first time I actually enjoy reading that article! :)

The only problem I encountered so far is that I couldn't read Cyrillic fonts, which US people obviously consider unessential for their customers. However, it's quite important for me! So, after an hour and so unhappy searching the net, I found this extremely simple tutorial how to do the trick. In short - you can either use a patch for the firmware  (which however will eliminate the warranty) or you can convert your books to embed their own fonts and then, you can see the Cyrillic. I chose the second option and then I spent some quality time looking for an EASY way to embed fonts into EPUB file. Needless to say that this was my first time hearing about epub files :)

Anyway, he's the best solution I found so far:

Embedding your fonts into ePub automatically using Calibre
1. Download Calibre for your OS (Win/Lin/Mac) and install it;
2. Download the attached plugin file (originally from Paul Tomashevskyi, GPL, see MobileRead thread)
3. Install it via Calibre's Preferences> Plugins: provide the path to the downloaded plugin and click "Add" button;
4. Check that it has appeared in the list of plugins at File type plugins branch under EPUB Font embedding plugin name and it's enabled (which is a default behavior on plugin addition);
5. Now open Preferences> Conversion> Look & Feel and add the following CSS declaration into Extra CSS area:
Code:
body {
font-family: "Liberation", sans-serif;
}
This will tell Calibre that we want to use "Liberation" font family we're going to embed into converted ePub content and it will add the font-family into own styles when it parses your ePub contents;
7. Add your content - which lacks embedded fonts and CSS declarations OR its embedded fonts aren't capable of providing glyphs for our UTF codepoints - into Calibre's library;
8. Select (or highlight) the content in the library list;
9. Proceed with the next toolbar icon and its option: Convert E-Books> Convert individually;
10. Set input format and output format to EPUB;
11. Check Look & Feel and that Extra CSS area contains what's been specified in (5) (On Windows it was okay while under Ubuntu it took a couple of restarts for the defaults we set in (5) to pop up on actual conversions in the app: dunno, guess I did something dead wrong);
12. Click OK.
Your ebook gets converted into EPUB and we end up having a set of Calibre's own UTF aware fonts (Liberation, serif set) embedded into it. source
It looks long, but actually it's very very quick. It took me like 15 minutes with the installation of Calibre and the plugin! This cool program even has a plugin for Sony Readers! And it works awesomely in Linux and it recognized and mounted the Reader without any help from my side. I just did the steps and I had my first Cyrillic book on my Reader. The only thing that didn't get converted, who knows why, are the titles of the chapters. But the text is fine and perfectly readable.

If anyone else encounters this problem - this is the way! Also, you can use other fonts (see the source), but I didn't bother. This one works fine for me and that's the most important.
Cheers!

Edit:
I had one more problem with some titles, who won't show properly. It turned out that they had the idiotic option "font-variant:small-caps" in their original css. Because that option is not included in the Liberation font, the font won't show those letters in Cyrillic (but in ??? instead).
Thanks to a Belorussian friend Vad, a solution is available.

One has to open the epub file manually (in Calibre, select the book and press T) and then to edit the css, by deleting all the "font-variant:small-caps" in it. Save it, close the folder, rebuild the epub and that's it.
You have titles in Cyrillic too.

събота, 13 ноември 2010 г.

Access shared folders on VirtualBox XP

Today I needed to use some shared folders on my Windows XP VirtualBox machine and it turned out that there is no obvious way to do that. I searched a little with Google and here is what remarkable HOWTO I found.

VirtualBox: access shared folders from Windows XP guest OS


What you need to do, is so very very simple.
Win+E -> open and explorer window -> click on the plus sign on My Network Places -> click on the plus sign of My Entire Network and there you go!

It's done. Really really simple, I have no idea why it doesn't work from My computer, but honestly, I don't care. Like at all. I use my VirtualBox XP for testing purposes so I don't give a damn what works and what not. The point is that now I know how to use shared folders without reading bugs or using some ridiculously complicated howtos that I won't cite here.

P.S. You need VM Virtual Box Guest Additions for this to work. To install them Devices -> Additions or Host+D

сряда, 10 ноември 2010 г.

How to make symbolic link that works!

I admit, I have some problems grasping the use of symbolic links in Linux. It just never works for me, no matter what I type. So here is the best piece of advice I found on this, ever:

How do I create a symbolic link?

ln -s [TARGET DIRECTORY OR FILE] ./[SHORTCUT]

For example:

ln -s /usr/local/apache/logs ./logs

This points a symbolic link "./logs" to "/usr/local/apache/logs" source

Why this is cool?
Because it creates a new file called "logs", which links directly to the directory you want to. I used it with Wine, because it didn't allow me to install a game in other directory than home, so what I did was
ln -s /media/D/dir ~/.wine/dosdevices/t:
And voila! It worked! Here t: is a letter that I didn't have before - it created this new shortcut "file" and this time, the link was fine and the game was installed on another harddrive (which was the actual point of the exercise). Weeee!

вторник, 9 ноември 2010 г.

Wine and sound

Today Rosetta Stone told me "Rosetta Stone could not find a sound output". I remembered I used to have that problem and after a little bit of searching, I discovered the solution:

In wineconfig audio tab:

1 check alsa
UNCHECK oss (and others)

2 EDIT ~/.asoundrc
comment out:
pcm.!default { type pulse }
ctl.!default { type pulse } 
  source - WineHq
This worked for me, without killing pulseaudio or anything like this.
Other suggestions for similar problem you can find here or here but I didn't try them. Now the audio is working and everything is fine.

Another Wine problem I had was the following:
"Warning: could not find DOS drive for current working directory '[My username directory]', starting in the Windows directory.
wine: cannot find '[File location]'"
Which I solved again using WineHq forum by doing:
ln -s / ~/.wine/dosdevices/z:

And it worked! 

Instead of intro

In short, this blog is not about writing, but about cool new Linux tricks I learn. I have no idea how often I will write, but I think the posts will be VERY short. It's just another scrapbook, to store useful info. Enjoy!