понеделник, 19 декември 2011 г.

How to opt out of Google WIFI Database

While browsing trough the news, I discovered this potentially helpfull information:
"Under the agreement, which was announced by Google and the Dutch Data Protection Authority, owners of Wi-Fi routers can add “_nomap” to the end of a router’s name to tell Google that they do not want its information included."source
I don't know if or when I will change the name of my rooter, but it's good to know in case you need it. After all, paranoia aside, but the article goes on like this:
"If many people opt out of the registry, Google’s ability to offer location-based services could be compromised. The company would then have to use cell tower locations and the Global Positioning System to determine a phone’s location, which could result in less accuracy and greater use of battery power." source
I personally don't see any reason why Google should know my geographic location, nor why I should be interested in anything Google can offer me to buy. And the idea of using my GPS location without my explicit consent is outrightly spooky! That's why I almost never turn on the GPS on my phone. And I never registered my Android with my Gmail account. It might be a tiny victory for the mankind, but it makes me feel good :)
So I guess it's not a bad idea to make the effort and change the name of the rooter. Even if only in the name of making Google little bit more miserable :)

понеделник, 5 декември 2011 г.

How to load subtitles in Kaffeine Player

Ok, it was a long night, but finally I solved a problem that was bugging me for quite a while.
I love Kaffeine, it's a great player, but at one point, it stopped displaying subtitles. What's worst, I couldn't find how to load them from external file and well, I stopped using it.
Today, I finally found out how to deal with Kaffeine.

To load subtitles, following the instructions here:
Click on Playlist, right-click on the movie file you're displaying and in the context menu you'll find: Load subtitles.
Another serious problem is that the subtitles are ridiculously small. It was a real pain figuring that out, but with the help of link1 and link2, I managed it.
To change the size of the subtitles:
1. Open the file: /home/user/.kde4/share/apps/kaffeine/xine-config
2. Find the line saying subtitles.separate.subtitle_size: tiny
3. Uncomment that line (remove the #) if it is commented, and change "tiny" to whatever size you prefer (tiny  small  normal  large  very large  huge). I tried with "large" and the subs became visibly big. So this one is working. You can also change the font from here, uncommenting the line: #subtitles.separate.font:sans but I didn't need to do that.
Well, that's it.
The mystery called subtitles in Kaffeine was solved. Weee!

P.S. If you need to replace some font of Xine, you can do it in the following directory:
/usr/share/xine/libxine1/fonts/

петък, 2 декември 2011 г.

Convert png to eps

Yesterday, I had to convert some png files to high quality eps files and it wasn't an option to directly export the figures to eps files. It turned out the problem is not so simple, but anyway, here's what I've found.
First, there are some free programs which enable you to make pretty vector graphs, diagrams and so on: Inkscape, graphviz, TikZ and Ipe. source
The problem in my case was that I have to use png files. What's more, they had to use pretty. Well, the biggest problem seemed to be the resolution. Before exporting the figure to whatever, zoom it to the max. You need at least 300dpi, some say 600dpi. That means a figure which covers the whole computer screen (well, mine is a laptop screen). If you capture it from pdf, then zoom to 300% and then capture the figure. This should produce a decent-looking figure.
More on the issue of resolution:
*Try png2pdf or a similar tool specifying in it interpolation to be off source
* \setlength{\pdfpxdimen}{1in/150} % Define resolution of PDF source
* Convert the png->eps->pdf->eps
1.The resolution of the image in pixels should be 300 times the size of the image in inches as it appears in the document. So for example a 2 inch by 3 inch image should have a resolution of at least 600 by 900.

2. ps2pdf -sPAPERSIZE=letter -dMaxSubsetPct=100 -dCompatibilityLevel=1.3 -dSubsetFonts=true -dEmbedAllFonts=true -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -dMonoImageFilter=/FlateEncode Fig1_a.eps Fig1_a.pdf
pdftops -eps Fig1_a.pdf Fig1_a
ps2eps Fig1_a
/home/denijane/Fig1_a.eps source
3. I tried also the following step (but they didn't help)
1. Save a Matlab figure from Matlab to EPS format.
2. Run ps2pdf14 -dPDFSETTINGS=/prepress unembedded_fig.eps embedded_fig.pdf.
Note: You can check the font is embedded by running
pdffonts embedded_fig.pdf
and check that the normal Helvetica font is embedd as BGISHF+Helvetica, for example.
3. You can either build your latex document with pdflatex, usepackage{graphicx} & \includegraphics{embedded_fig.pdf}, OR
4. run pdftops -eps embedded_fig.pdf embedded_fig.eps
5. run ps2eps embedded_fig.eps
which will crop eps to bounding box.
6. rename embedded_fig.eps.eps to embedded_fig.eps
7. Build your latex document with latex, usepackage{graphicx} & \includegraphics{embedded_fig.eps}.

Finally, check the font is embedded by running
pdffonts ~/my_article.pdf
 and check that the normal Helvetica font is embedd as BGISHF+Helvetica. source
4. The package bmeps: To convert from png to high level eps use:
bmeps -a -leps image.png
bmeps image.png image.eps
bmeps -l eps2 fbt.png fbt2.eps
And also, the following packages might help:
\usepackage[T1]{fontenc}
\usepackage{ifpdf}
\usepackage{graphicx}
source
For eps file level 3:
bmeps -l eps3 Fig9_b.png Fig9_b.eps
or
convert Fig1_a.png EPS3:Fig1_a.eps

сряда, 9 ноември 2011 г.

How to enable/disable/empty the swap


My Sabayon seems to have the habit of writing stuff into the swap and then forgetting about them. So I thought for a while, why not just empty the swap when it's full and I'm sure nothing is using it. Well, it turned out it's possible to do so. Thanks to this forum post, now I know how.
So, there are the commands:
>$swapoff
>$swapon
which can be safely used to turn on and off the swap. Now, the source site suggests using ">$swapoff /dev/hdxx" but if you have only one swap partition (like I do) this is unnecessary.
All you need to do is (as sudo, of course):
>$swapoff -a
and after it finishes emptying your swap,
>$swapon -a
And it's done. You have a fresh swap file, which you can start trashing immediately.
Now, if you do that when a program is still writing to the swap, I don't know what will happen. Maybe something ugly, maybe not. I tested it when nothing was using the swap even though my ram was almost full, and I haven't noticed any problems for now.
Enjoy!

понеделник, 3 октомври 2011 г.

Radio in Linux

I'm a big fan of listening to radio, so for me, it was very important to have a way to listen to may favorite stations while I'm working on my laptop.
So, to listen to online radio in Linux, you need very few things.
Mainly:
GStreamer (python-gst >= 0.10) for the audio processing.
Using GStreamer, you can play radio from url using:
$gst-launch-0.10 playbin uri=http://ns57.ovh.net:80/
In this example, the radio is Alouette, a French radio. Of course,  you can use any kinds of streaming url-s.
If you need an application to play your favorite radio stations, you can use pretty much all the players, and if you install the package kradio, you can also receive information about the song being played in real time.
Finally, an application I found just today is radiotray-0.6.4. It is very sweet and light (28Mb right now), it installs a tray, from where you can change easily all the stations you like. You can also add stations using the gui, to sort them, put them in different groups and so on. If you're not such a fan of gui or you want to import a larger list, then the config files are found in
~/.local/share/radiotray/
There are two files, from where you can set up the configs of the player and also the PLAYLIST.
Just open bookmarks.xml with your favorite text editor and use
<group name="My stations">
 <bookmark name="cherieFM" url="http://mp3.live.tv-radio.com/cherie_fm/all/che_124310.mp3"/> 
<bookmark name="NRJ Hits" url="http://mp3.live.tv-radio.com/nrj_hits/all/nrj_150726.mp3"/> 
</group>
to list your favorite stations and order them in whatever way you find suitable.
Enjoy!

петък, 26 август 2011 г.

How to convert png to pdf

Ok, as always Libre Office Impress does strange things with slides design when I do export to PDF so I got creative.
1. Export to PNG from File->Export (you could do it for all slides trough Export->Html, but somehow the quality appears worst)
2. Make sure you name you pngs correctly: Pic001.png, Pic002.png
3.  convert Pic0*.png -quality 100 document.pdf
Et voila!
Now, convert has some pretty cool options, make sure to check the man pages if you want to do something more fancy.
Another cool thing I discovered is how to convert png to eps!

sam2p pic1.png EPS:pic1.eps (source)
It works awesomely and makes even 3d plots look good. Of course, you could use also convert:

convert fig.png eps3:fig.eps 
(source)
Nice huh?

неделя, 17 юли 2011 г.

Free online proxies

Everybody needs a proxy from time to time, whether because you get banned from a site by a stupid bot and you need an admin's attention to remove the ban or simply because you need to see something blocked for your country for totally silly reasons.
So here's some cool sites I discovered these days:
1. Use Google as a proxy (source)! So very simple:
http://www.google.com/translate?langpair=en|en&u=www.forbiddensite.com
Unfortunately, the english to english translation is already removed by Google, but you can always translate to some other language you know. Works for porn, lol.
2. List of free online proxies
Enjoy!

неделя, 19 юни 2011 г.

How to find out the hfloat digits of your computer

Don't ask why I needed it, the point is that at this site, I found out how.
Save this program to some file, say pro.c:
#include <stdio.h>
int main()
{
long double ld = 1.0/3;
double d = 1.0/3;
float f = 1.0/3;

printf("sizeof(float)=%lu\n", sizeof(float));
printf("sizeof(double)=%lu\n", sizeof(double));
printf("sizeof(long double)=%lu\n", sizeof(long double));

printf(" f=%.30lf\n", f);
printf(" d=%.30lf\n", d);
printf("ld=%.30Lf\n", ld);
}

And then compile it:
gcc pro.c -o pro.x
After you compile it, type ./pro.x and count the digits :)
If you're interested into floating point arithmetics in Linux, you can read this site or of course - wikipedia.

вторник, 14 юни 2011 г.

How to suspend trough console

Easy :)
pm-suspend

pm-suspend
# sleep to ram
pm-hibernate
# suspends to hard-disk

Also it appears you can suspend at certain time trough:
at 0100
pm-suspend
<ctrl-D>
And to wake up the computer with:
rtcwake

събота, 23 април 2011 г.

How to remove pulseaudio

Since the last 1 or 2 kernels I have horrible problems with pulseaudio. It's a very annoying bug that causes KDE to freeze for 15-20 minutes by loading whatever program is using sound with 2GB RAM. Which makes the system to start placing stuff in the swap and the whole situation becomes very ugly.
The actual error is:
"snd_pcm_avail() returned a value that is exceptionally large"
and obviously is some bug in pulseaudio. I discovered some sites claiming to have a solution (like this) but nothing helped.
So last night I decided to remove the annoying pulseaudio.
I did as suggested in this site. Note, I did backup ~/.asoundrc, ~/.pulse and /etc/asound.conf just to be on the safe side.
Then use:
touch ~/.pulse-a11y-nostart
echo autospawn = no|tee -a ~/.pulse/client.conf
killall pulseaudio

to kill pulseaudio and tell it to please do not appear again. If you happen to want it back, you can use:
rm .pulse-a11y-nostart ~/.pulse/client.conf .asoundrc
.

Unfortunately, it continued to start on reboot. I tried to uninstall it, but it turned out that the whole KDE depends in some mystical way on it, so I found the other solution:
mv /usr/bin/pulseaudio /usr/bin/pulsestop
That removes the bin file of pulseaudio and it cannot start even if it wants to. Oh, well.
Next thing was that I had problems with amarok not wanting to play music. It turned out that my first backend is "vlc" and not "xine". After putting "xine" on fist place, sound appeared.
I also used the .asoundrc suggested in the file above:

pcm.dsp {
    type plug
    slave.pcm "dmixer"
}
pcm.!default {
    type plug
    slave.pcm "dmixer"
}
ctl.!default {
        type hw
        card 0
        }
pcm.dmixer  {
        type dmix
        ipc_key 1024
        slave {
            pcm "hw:0,0"
            period_time 0
         #   period_time 84000
         #   period_size 2048
         #   buffer_time 340000
              rate 44100
         #   rate 48000
              period_size 1024
         #    buffer_size 2052
              buffer_size 4096 # this is the size of buffer I use
        #   buffer_size 8192
        #   buffer_size 16384
        }
        bindings {
            0 0
            1 1
        }
    }
    ctl.dmixer {
        type hw
        card 0
    }
Now everything seems to work fine. Amarok plays music. Juk plays music. If you stop Amarok and then run Flash, it has sounds. They won't work simultaneously, even though Amarok and Juk work in the same time. Anyway, this is very small problem compared to the disastrous bug in pulseaudio that made me lose hours in the recent weeks. Now everything is calm and nice. :)

вторник, 5 април 2011 г.

How to install skype for android directly

Today, I decided I need skype on my phone, because I didn't have mic on the computer. It turned out that you can install it trough skype.com/m but only after a "free sms". I don't care how free is that sms, I'm just very suspicious towards services which want my phone or address for no reason at all. So after some digging, I found this site, where you can install skype mobile directly.
What you do is to open this site trough Opera, and click on the link skype3G.apk. Then when Opera downloads it, you click open and install it happily. And that's it. Nice and easy. And no Android Market, no Skype dependence.
Enjoy!

петък, 18 март 2011 г.

How to connect to internet trough terminal?

First, check out this cool site for Linux command. You probably already know most of them, but still, it's a useful reminder.

Code Listing 3.11: Using ifconfig
# ifconfig eth0 ${IP_ADDR} broadcast ${BROADCAST} netmask ${NETMASK} up
Now set up routing using route. Substitute ${GATEWAY} with your gateway IP address:

Code Listing 3.12: Using route
# route add default gw ${GATEWAY}
Now open /etc/resolv.conf with your favorite editor (in our example, we use nano):

Code Listing 3.13: Creating /etc/resolv.conf
# nano -w /etc/resolv.conf
Now fill in your nameserver(s) using the following as a template. Make sure you substitute ${NAMESERVER1} and ${NAMESERVER2} with the appropriate nameserver addresses:

Code Listing 3.14: /etc/resolv.conf template
nameserver ${NAMESERVER1}
nameserver ${NAMESERVER2}
source - Gentoo wiki
Also if you want to connect trough wifi, use this wiki:

  1. Connecting to an OPEN / WEP WLAN (DHCP)
    1. iwconfig yourinterface mode managed key yourwepkey(128 bit WEP use 26 hex characters, 64 bit WEP uses 10)
    2. iwconfig yourinterface essid youressid (Specify ESSID for the WLAN)
    3. dhclient yourinterface(to receive an IP address, netmask, DNS server and default gateway from the Access Point)
  2. Connecting to an OPEN / WEP WLAN (Manual IP Setup)
    1. iwconfig yourinterface mode managed key yourwepkey (128 bit WEP use 26 hex characters, 64 bit WEP uses 10)
    2. iwconfig yourinterface essid youressid (Specify ESSID for the WLAN)
    3. ifconfig yourinterface youripaddress netmask yoursubnetmask
    4. route add default gw yourgateway (Configure your default gateway; usually the IP of the Access Point)
    5. echo nameserver yourdnsserver >> /etc/resolve.conf (Configure your DNS server)
There are also some very useful commands on this site.  The most important:
ifconfig [interface] up (bring up specified interface)

ifconfig [interface] down (take down specified interface)

ifconfig [interface] hw ether [MAC] (Change the wireless cards MAC address, specify in format 11:11:11:11:11:11)

And finally, you can try this, if you want to automate the process.

вторник, 1 март 2011 г.

How to make Amarok see changes in tags?

I installed easytag to edit somewhat the tags of my songs, since Amarok has some problem going from cp1251 to unicode . So I edited my tags, but Amarok didn't update them. I searched a little and found this extremely useful command:
find /media/music -exec touch {} \; 
What it does is to change the date to all files in the directory and thus when Amarok rescan the collection (I forced it with update collection), it sees the new tags and everything is nice again. Source

неделя, 20 февруари 2011 г.

How to use png2swf and how to export swf with recordmydesktop

Ok, I lost two days with this but I think I'm close to perfection. Or as close as I could get without trashing the computer :)
So you have a presentation which you want to make to an animation. With Open Office you can export to swf, but I wasn't very happy with the quality of the export. Because I have tons of high quality pictures in the presentation. Anyway. What I did is I used "export to html". This creates a bunch of png files. Then you take the pngs and you make them to a swf. How? Easy!
1. Install swftools (http://www.swftools.org/)
2. Then use png2swf. I tested quite many options but for some reason not all of them work that well on my laptop. Anyway, what worked was this.
png2swf -o poster.swf -r 0.4 img0.png img1.png
What it does is to create the file poster.swf which shows 0.4 slides per second. I tried with 1slide per second but it was too quick for my gorgeous slides.
Now you have the swf you of course need to convert it to something youtube likes. The kind of claim they recognize swf files but for some reason it didn't work for mine. But first try, maybe you'll be lucky. If you don't, here comes the funny part. I couldn't find anything to convert the swf to flv in Linux. Maybe it's my fault but anyway. I didn't find anything that can do the same in Windows either. Sure there are many programs, but first my slides are huge and the quality is very important and second I won't buy anything. So after spending almost a day searching for a good free option, I settled for the simplest decision. I recorded my screen! Now that was fun!
3. Install recordmydesktop and/or gtk-recordmydesktop. For some absolutely unknown to me reason the gtk-version gave me better results. But only after experimenting for hour or so with the command version.
4. Set you swf to play in Konqueror (or else but that's what I had) and I did it on Fullscreen with no toolbars.
5. Type xwininfo and point to the window you will record. Don't point it on the taskbar, because that will record only the taskbar :) I did that already. So use alt+tab to point it.
And then:
6. recordmydesktop --windowid 0x460008a --workdir /home/denijane/rec --delay 5[s] -o /home/denijane/rec/test4.ogg --no-sound --fps 24 --width 1100 --height 773 -x 90  --stop-shortcut Control+Shift+S
This huge thing is the command that records only the part of the screen that shows the slideshow. Here's what each of the stuffs do:
--windowid X - X is the ide you get from xwininfo . The first part of it only. From there you can get the dimensions of the window as well which are useful when setting the region to record.
--workdir is where your temp stuff will be recorded.
--delay - this means that the recording will start 5 secs after you execute the command. Very useful if you don't want to record your terminal.
-o gives the full name of the file you're about to record.
--no-sound - I didn't have any sounds on my slides, so I used that to minimize resources and be able to listen to music while recording
--fps 24 - crucial option - it fixes your frames per second. Though when you work with slides they don't change that often but still.
--width and --height are clear. They let you record only the slides and not the whole window.
-x 90 - horizontal offset, this let you move the record window to the right.
--stop-shortcut - this lets you stop the recording without switching the window. Very handy.


So after I came up with all those settings, I had the feeling it didn't work that well. I'm not sure, because I didn't try that in youtube and my ogv player kind of sucked. So what I did is that I used the gtk version.
7. Alt+F2 -> gtk-recordmydesktop
8. Again select the window you want to record. Maxout the audio/video settings. Then hit Advanced. Set the frames per second. You can set a working directory but this is useful only if something crashes (otherwise those files get deleted after the compression). In Misc add in the Extra options: --delay 5[s] -o /home/denijane/rec/test5 --width 1100 --height 773 -x 90  --stop-shortcut Control+Shift+S This will do precisely the same as in terminal, just here it worked better. Or the same. Anyway, my video is in youtube (http://www.youtube.com/watch?v=yQRgQrZZblw) for now. It's not the final cut, but it's the best so far :)
WARNING: DO NOT, I repeat DO NOT hit alt+f2 and type recordmydesktop. Because that will start recording and you'll have to kill it before it eats all of your free space. I say it because I did it :)

понеделник, 7 февруари 2011 г.

White noise generators in Linux

1. cat /dev/urandom > /dev/dsp
2. Boodler (http://boodler.org) Very nice open-source soundscape tool. You can install number of packages with sound samples and then to run them simultaneously or one after another. You should read the lengthy instructions, but once you get it, it's quite simple actually.
3. Baudline - some I haven't yet managed to work for me, but it looks quite promising.
4. Audacity
5. Online generator: http://www.speechprivacysystems.com/white-noise/ .  You can use Waterfall, Wind, Static, Rain and Beach noises and to mix them for free.
(More).

сряда, 2 февруари 2011 г.

How to root Android phone X8

I do it on windows xp sp3 (before I try to do on win7 32b)
1. Install Sony_Ericsson_PC_Companion_2.01.078_Web
2. Install .net framework 2.0
3. Connect phon to PC with activated USB-Debugging (DO NOT MOUNT THE SD-CARD!!!!)
4. Wait a few seconds (to recognized phone by system)
5. Root by SuperOneClickv1.3.0 (from topic ) source

четвъртък, 27 януари 2011 г.

Amarok not showing Cyrillic tags

Obviously the problem comes from the different Cyrillization of Windows and Linux systems. Songs that were tagged with cp1251 are not properly read by systems that use unicode.
The solution?
Well, you download a script from this site and then you do:
chmod +x tag2utf.py
./tag2utf.py /path/to/mp3
I tested it and it looks like it's working. It will ask you whether the original cyrillization is cp1251 or koi8-r. And you time c for the former and k for the latter. And that's all.
Enjoy!

source