вторник, 17 декември 2013 г.

Not enough place on my /tmp???

Today, I realized just how small is my /tmp partition by default. It turned out that it's only 100MB and if you happen not to like restarting, just like me, you will run out of space sooner rather than later.
In principle, the /tmp partition gets emptied upon reboot (you can check for your reboot rules with $nano /etc/conf.d/bootmisc ) , but in my case, this is no good. So what can you do?
First, you can change your /tmp size.
1. $su -c "nano /etc/fstab"
2. Change the line concerning the /tmp. In my case, I made it:
tmpfs                   /tmp                    tmpfs   noexec,nosuid,nodev,size=1000M 0 0
3. After restart, check your tmp size with:
$df -h
I still have to restart to see if it works. In the mean time,you can try deleting your /tmp to free some space. Like
$cd /tmp
$sudo rm -r *
Do the last one only from inside your /tmp dir! Otherwise, you might delete more than you want and much more than it is healthy!!!
Another smart way to increase the /tmp size without restarting can be found here
Finally, I just discovered this Sabayn wiki on how to optimize your system, where you can find how to mount your /tmp partition on your ram so that everything runs faster. I currently have 16GB ram so I guess it makes some sense to do that.

Ram Drive using tmpfs

Because temp folders are cleared during shutdown, it is safe to place their storage locations in RAM. This reduces the number of disk operations, making programs that use temp folders faster. Open the file and append the lines: file: /etc/fstab
  ...
  tmp     /tmp      tmpfs rw,mode=1777 0 0
  vartmp  /var/tmp  tmpfs rw,mode=1777 0 0 
"mode=1777" option allows all users write access, but prevents deletion of files belonging to other users.

I'll try this later, and we'll see how it works. 


събота, 7 декември 2013 г.

Atheros AR9485 kills my wifi router (solved)

Ok, here's the story:
I have a laptop with atheros ar9485. The wired connection works fine, but the moment I connect to my wifi TENDA router, the wireless network dies. And by dies, I mean that it disappears and the router needs to be manually rebooted.
I used another router (OpenWrt), and it doesn't crash. But the connection is very unstable, it drops at random.
I still don't know whether the problem was between the Atheros and the Tenda router (I read somewhere that Atheros has a problem with Netgear routers), but it doesn't matter. Here's how I fixed it.
First, as suggested in the Sabayon Forum (link), I got the outputs from:
uname -a
rfkill list
iwconfig (before the router crash)
iwconfig (after)
dmesg|tail -25

The output from the dmesg looked like this:
[ 5858.487813] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 5858.487817] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
[ 5858.487821] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 5858.487824] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 5859.529403] wlan0: authenticate with c8:3a:35:27:51:58
[ 5859.548446] wlan0: send auth to c8:3a:35:27:51:58 (try 1/3)
[ 5859.550322] wlan0: authenticated
[ 5859.551076] wlan0: associate with c8:3a:35:27:51:58 (try 1/3)
[ 5859.612983] wlan0: RX AssocResp from c8:3a:35:27:51:58 (capab=0x11 status=0 aid=1)
[ 5859.613012] wlan0: associated
[ 5859.613079] cfg80211: Calling CRDA for country: CN
[ 5859.614768] ath: regdomain 0x809c updated by CountryIE
[ 5859.614771] ath: EEPROM regdomain: 0x809c
[ 5859.614772] ath: EEPROM indicates we should expect a country code
[ 5859.614773] ath: doing EEPROM country->regdmn map search
[ 5859.614774] ath: country maps to regdmn code: 0x52
[ 5859.614775] ath: Country alpha2 being used: CN
[ 5859.614776] ath: Regpair used: 0x52
[ 5859.614790] cfg80211: Regulatory domain changed to country: CN
[ 5859.614791] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[ 5859.614793] cfg80211:   (2402000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm)
[ 5859.614794] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (N/A, 3000 mBm)
[ 5859.614796] cfg80211:   (57240000 KHz - 59400000 KHz @ 2160000 KHz), (N/A, 2800 mBm)
[ 5859.614797] cfg80211:   (59400000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 4400 mBm)
[ 5859.614798] cfg80211:   (63720000 KHz - 65880000 KHz @ 2160000 KHz), (N/A, 2800 mBm)


So after some digging, I discovered that there seems to be a problem with CRDA and the network adapter identification. You can see more on the story here and here. There you can find also some recommended solutions, but what I did is the following:

sudo equo install crda (if you don't have it)
sudo nano /etc/default/crda

and added this line: 
REGDOMAIN=BG 
And that was it. I got this solution from this site. It turned out it worked. Now, the connection is stable and the router - alive. 
I lost half a day on this, but now I feel quite happier. And I have wireless :) 
Enjoy!

събота, 23 ноември 2013 г.

tomtom mydrive not installing

Well, not really a Linux related post, but anyway.
I had to install tomtom's mydrive on a Windows XP machine. It couln't install for no obvious reasons. The machine had the .net 4.0 and SP3, but it was very unclear what the problem was. I tried installing it on my Sabayon with Wine and it turned out it installed just fine. It couldn't run and I thought the reason is that I don't have the .net 4.0 installed, so I did:
$­wget http://winetricks.googlecode.com/svn/trunk/src/winetricks
$ bash winetricks dotnet40 corefonts
It didn't help, really, but then I checked in wine for the tomtom app. And thanks to it, I found out that 1) it won't run under wine because of " KERNEL32.dll.SetVolumeMountPointW" which has not been implemented so far.
2) You need Microsoft Visual C++ 2005 SP1 runtime to run it!
Voila! That was the problem the whole time. Since the Windows machine has been used only for browsing, nobody bothered to install Visual C on it. The tomtom app of course didn't feel obligated to report this problem, it just crashed silently leaving me scratching my head. After installing it, the app installed fine, connected the device and started updating. It still has not finished, but at least it is working.
My biggest surprise was that my Sabayon recognised the tomtom protocol (network type) and connected fine. It was unbelievable. So, that's the story for today.

понеделник, 7 октомври 2013 г.

How to embed cyrillic subtitles in a video, 2013

Finally I got this to work. I needed to embed Cyrillic subtitles in a video, to be able to watch it on a lame device which likes to screw the subtitles (which it would otherwise read ok).
Anyway, we tried this for quite long but the final try was the working one. I follow this guide.
1. First, locate a working Cyrillic font. I ran a kfind to find Tahoma.TTF
2. Edit ~./mplayer/config
and add:
# Set font.
#set your ttf fonts here, example:
font=/path/to/Tahoma.TTF
# Set font encoding.
subfont-encoding=unicode
# Set subtitle file encoding.
unicode=yes
utf8=yes
3. Close this file.
4. Open your subtitles file with kwrite and then click Save As and pick UTF8 as encoding.
5. Well, that's it, then just use:
$ mencoder -UTF8 -sub movie_subtitle.srt -ovc xvid -xvidencopts bitrate=70000 -oac copy -o new.movie.name.avi movie.avi
and mencoder will do the rest. Well, it takes some time, but it works.
Note, if you do -ovc copy, it won't embed the subtitles, just copy the whole movie.
I'm not sure how high you should go with bitrate.
Also, I've found this: -subfont-text-scale 3
if you want to increase the font size. I haven't tried it yet.
For people wanting to try with cp1251, you can try this link, but it didn't work with me.
You can also read this guide, with which you can do a lot of cool things. But all I need is to embed the subtitles, so I'm fine with this command.
Enjoy!

петък, 13 септември 2013 г.

How to send email trough console (smtp)

This one took me a whole lot of nerves to figure it out, and in the end, it turned out I was sleeping the whole time.
The idea was to backup the database of my forum and to send it to an email. There are lots of sites suggesting ways to do it, but here's my final choice (source):

NOW="$(date +"%m%d%Y")"
/usr/bin/mysqldump -hlocalhost -uDBUSER -pDBPass DBName | gzip > /BCKlocation/BCK_NAME$NOW.sql.gz
nail -r "sender@email.com" -s "test" -a /BCKlocation/BCK_NAME$NOW.sql.gz RECIPIENT@email.com
This will attach your backup to the email and send it to the recipient email. I spent the whole night trying this, until I figured that the last option is the recipient email and nothing else. It turned out I was sending myself emails on the email I thought I'm sending them from. Quite stupid, but anyway. Note, it's better not to write your password in a file, so if you have the option to do this trough ssh, it's better to use only -p .

Now comes the funny part - how to set up the smtp. Well, I did it with a .mailrc file in which I put:

set smtp=smtp://name.of.the smtp.server:port
set ssl-verify=ignore
set from=user@domain.com
set smtp-auth=login
set smtp-auth-user=user@domain.com
set smtp-auth-password=password

This options depend on your hosting, so you need to check them there. You can also set them without the .mailrc file, just by typing
mailx -v -s "$EMAIL_SUBJECT -S smtp-use-starttls -S ... $TO_EMAIL_ADDRESS
where ... are all of the options you have in the .mailrc.

But that's all. Doing this, you can happily send yourself emails, reminders, and other goodies, just for the fun of it.
The nice part is that you don't need to use your hosting email to do that, you can use any email server supporting smtp.

If you want to use gmail, here's the smtp setting:

set smtp-use-starttls
set ssl-verify=ignore
set smtp=smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=name@gmail.com
set smtp-auth-password=pass
set from=name@gmail.com

and the command:

$ mailx -v -s "$EMAIL_SUBJECT" $TO_EMAIL_ADDRESS
Nice, huh!
For the man of nail and all its cool options you can see here.

четвъртък, 8 август 2013 г.

How to trim mp3 file with Linux

The short answer:
$ffmpeg -ss 0:00:00.0 -t 00:02:03.9 -i file.mp3 -acodec copy  new_file.mp3
This command will create a file lasting 2:03:9mins.
The longer version was that I desperately wanted to cut the end of one youtube downloaded mp3 file, but for some reason I couldn't do it with
$sudo mpgsplit -X file.mp3 [00:00:00-00:01:45] -o file_crop.mp3
(It told me "mmm, this file does not start with a pack, offset: -2 " and when I tried the "desperate mode" I got an endless loop - FUN!).
So I wanted to find something simple, instead of using Audacity, which seems too complicated for my simple needs. So this was my simple solution.
Note, ffmpeg gives you the following jolly message:
"This program is not developed anymore and is only provided for compatibility. Use avconv instead (see Changelog for the list of incompatible changes)."
But it still works, so anyway.
As for Audacity, you can do the same quite easily (it turns out) - just look at the bottom, there is Begining of Selection - End of selection. Type whatever you want and then click the first wave-button on the top right part of the screen "Trim audio". Then File->Export->mp3 and voila.
Well, can't compete with the one line solution of ffmpeg, right?

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

No streaming in Second Life

Not that I'm such a fan, but I do enter Second Life every once in a while. And for a long long time, I didn't have streaming, which meant very boring clubbing experience. Today I finally fixed it. I followed the instructions given here:
1. nano .secondlife-install/secondlife
2. UNCOMMENT the following entries (i.e. remove the # in the beginning) so that you have :
export LL_BAD_OPENAL_DRIVER=x

## - Avoids using the FMOD ESD audio driver.
export LL_BAD_FMOD_ESD=x
## - Avoids using the FMOD OSS audio driver.
 export LL_BAD_FMOD_OSS=x
And save (Ctrl+O)
Then, after restarting the client, I had music! Yay!

четвъртък, 14 февруари 2013 г.

Visualization in Amarok

Who would have thought that something so simple in Windows would be that complicated in Linux. So, yesterday, while listening to a quite nice song, I decided I wanted visualization desperately. I tried some script for Amarok involving buffer sample, but it kept on giving me an error. So I started digging and I came up with a solution. It's called Project M.
$sudo equo install libvisual libprojectm libvisual-projectm libprojectm-qt projectm-pulseaudio
I think those are the packages needed in order for Project M to run. Or they are what I have installed on my PC.
After installing, you can find Project M Pulse in your start menu. Now, don't think you'll have the normal winamp options - you wont. Or at least I haven't found them yet. But it's pretty and colorful. And it moves. :)

четвъртък, 7 февруари 2013 г.

How to reduce the size of a pdf

I needed to send a pdf, and it turned out way to big. Well, it was big, no doubt, since it consisted of 3 high-quality pictures, but anyway.
So, here's what I did.
$pdf2ps file.pdf file.ps
$ps2pdf file.ps file_.pdf
And the pdf got like 3 times smaller. Which was good. 

Essentially, you can achieve the same by opening the pdf in Okular and doing a print to pdf - this is how I did it the first time. 

There is, of course, the longer option: 

$gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=output.pdf input.pdf

where you can replace "/screen" with "/ebook", "/printer" or "/prepress" for higher quality (/screen being the worst, /prepress - the best). But if you increase the quality, the pdf will remain BIG. And for once, we want it smaller. :)



четвъртък, 10 януари 2013 г.

No sound from speakers, only from headphone

After the latest KDE update, it turned out, after plugging and unplugging the headphones, I don't get sound from the laptop's speakers. I think this is some kind of bug (see here), so I don't have a solution to this problem, however, in the same page, one can find out how to set the volume of the speakers trough Konsole, which more or less fixes the problem. Just type:
$amixer -c0 sset "Speaker" 100%
and you're done.
You can achieve the same by using:
$sudo alsamixer
and to manually increase the volume of the speakers, but the amixer way seems quicker.