Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Thursday, 21 April 2011

Mercurial In Ubuntu

Since I have moved to ZeroTurnaround I had to learn a lot of new and interesting things. Most of them are very simple to write about, but as time passes I finally thought up the things, I could share with you.

We use Mercurial as SCM. So here is a small tip for ubuntu users how to configure hg.

Mercurial is available to install through repository

$ sudo aptitude install mercurial

So now as it is installed, we can configure it. Mercurial reads configuration data from several files, if they exist. To list them use:

$ hg help config

Now we will edit the $HOME/.hgrc file to add there some user information, authentication and enable plugins. A configuration file consists of sections, led by a [section] header and followed by name = value entries (sometimes called configuration keys)

[ui]
username = Firstname Lastname <firstname.lastname@example.net>

Here we introduced ourselves. The section is [ui] and ui.username is typically a person's name and email address. If this field is not declared in hgrc, you will have to enter it manually every time you commit.

[auth]
foo.prefix=*
foo.username=firstname.lastname@example.net
foo.password=SecretPassword123

The [auth] section allows you to store credentials for http authentication, I hate entering username and password every time I pull or push. You can store several different credentials for different servers here. They will be grouped by the part before the . (full stop, foo - in my example). And the auth.prefix will determine, which credentials should be used for what http address. It should be either * or a URI with or without the scheme part. In my example 1 and the same credentials are used for all addresses.

[extensions]
fetch = 
color =
#this extension will get loaded from the file specified
myfeature = ~/.hgext/myfeature.py

Mercurial has an extension mechanism for adding new features. To enable an extension, create an entry for it in [extensions] section. There is a list of extensions for Mercurial and you can write one yourself. Extensions bundled with Mercurial does not need anything after the equals sign, but you need to provide the full path to others.

Now that we have configured it a little bit, we can start using. Mercurial tutorial by Joel Spolsky will teach you, how.

Friday, 17 December 2010

Solution: Eee Pc Ubuntu 10.10 Wireless Connection Fail After Resume From Hibernate

After upgrading your Ubuntu to Maverick, you may have experienced some problems using wireless networks. That is when your computer resumes from hibernate, it is no longer able to connect to any wireless network and only a restart will make it do it again. Also some random disconnects from wireless occur. That concerns not only Eee Pc (I have a 1000h), but I believe every computer that uses RaLink network controller. First, check if it is you :)

$ lspci -k|grep -i network --after-context 3
03:00.0 Network controller: RaLink RT2860
Subsystem: Foxconn International, Inc. Device e002
Kernel driver in use: rt2800pci
Kernel modules: rt2800pci, rt2860sta

With Ubuntu 10.10 some hardware that was previously driven by the rt2860sta driver is now driven by default by the rt2800pci driver. Sometimes the new rt2800pci does not work as well as the rt2860sta. In that case it is often possible to switch back by blacklisting. As we already saw, we have both drivers installed and the pci one in use. Now we will create a text file that will allow us to easily switch between the drivers.

sudo gedit /etc/modprobe.d/blacklist-wlan.conf

Copy these 2 lines into the newly created file.

blacklist rt2800pci
#install rt2860sta /bin/false

And save. After the reboot your computer will use the rt2860sta driver. If you want to switch back to the rt2800pci driver, just comment the first line, uncomment the second and reboot.

PS. Solution was found here

Wednesday, 25 August 2010

MongoDB With C++ In Ubuntu

Install standard repository package.

$ sudo aptitude install mongodb

Create data directory. By default mongo uses /data/db.

$ sudo mkdir -p /data/db/
$ sudo chown `id -u` /data/db

Try to run the server. (If you decided to use another path for data run mongod with --dbpath option)

$ mongod

If it runs, the you are ok. But if it throws an error

mongo: error while loading shared libraries: libmozjs.so: cannot open shared object file: No such file or directory

Then we will have to find that missing library.

$ find /usr/lib/* -name libmozjs.so
/usr/lib/firefox-3.6.8/libmozjs.so
/usr/lib/xulrunner-1.9.2.8/libmozjs.so
/usr/lib/xulrunner-devel-1.9.2.8/sdk/lib/libmozjs.so

Now create a symbolic link

$ cd /usr/lib
$ sudo ln -s xulrunner-devel-1.9.2.8/sdk/lib/libmozjs.so libmozjs.so

Now try to start the server again. It should be working. Start the client and run some queries:

$ mongo
> db.foo.save( { a : 1 } )
> db.foo.find()

Installing Libraries For C++

So the database is up and running, now we need some C++ libs to be able to connect to it.

$ sudo aptitude install libboost-all-dev libpcre++-dev

Now we should be able to run this code, to test the connection.

//tutorial.cpp
#include <iostream>
#include <mongo/client/dbclient.h>

using namespace std;

void run() {
  mongo::DBClientConnection c;
  c.connect("localhost");
}

int main() {
  try {
    run();
    cout << "connected ok" << endl;
  } catch( mongo::DBException &e ) {
    cout << "caught " << e.what() << endl;
  }
  return 0;
}

Build and run this code using:

$ g++ tutorial.cpp -lmongoclient -lboost_thread-mt -lboost_filesystem-mt -lboost_program_options-mt tutorial
$ ./tutorial
connected ok

Saturday, 23 January 2010

Remove User List From Ubuntu Karmic Login

As I use Ubuntu on my eeePC, I like better typing than using touchpad.

That would remove user list from login screen and will make you type your username instead of selecting it.

sudo -u gdm gconftool-2 --type bool --set /apps/gdm/simple-greeter/disable_user_list 'true'

Wednesday, 16 September 2009

Convert Different Audio In Command Line in Ubuntu

Converting different audio formats in Ubuntu is quite an easy task. Just start Soundconverter, or first install it, if you don't have.

sudo apt-get install soundconverter

But I needed to do it in command line. Soundconverter can do it either. (What a good boy!) But you just need to know the mime-type of the output file (simply adding the desired suffix doesn't work). For example, to convert "my_favourite mp3" to wav you can use:

soundconverter -b -m audio/x-wav -s .wav my_favourite.mp3

See the full list of mime types.

For the available options see

soundconverter -h

or

man soundconverter

Wednesday, 18 February 2009

How To Split Audio CD Image (.flac) Into Several Tracs In Ubuntu

$ sudo apt-get install cuetools shntool flac #install needed tools
$ cuebreakpoints sample.cue | shnsplit -o flac sample.flac #read breakpoints from cue and give them to splitter
$ cuetag sample.cue split-track*.flac #add tags to newly created files
More info is there.

Friday, 13 February 2009

Eee Control Tray For Ubuntu

eee-control-tray is a package that one can install on Ubuntu (or other Debian system) to obtain an easy interface to configure Fn shortcuts and other useful options.

Wednesday, 3 September 2008

Install Ubuntu 8.04 on Asus Eee PC 1000h

Приобрёл себе Asus Eee Pc 1000H. Установленный там Xandros что-то не очень вдохновил, поэтому решил поставить туда свою любимую Ubuntu. Что для этого нужно было сделать...

Создание загрузочной USB и установка Ubuntu.

Об создании загрузочной флэшки очень хорошо написано на официальном сайте Ubuntu. Я выбрал вариант с UNetbootin.

Загрузка и установка проблем вызвать не должна, поэтому детальное описание опускаю.

После установки

Не работает сеть (ни ethernet, ни wifi), некоторые комбинации клавиш (Fn+F2, Fn+F7, Fn+F8, Fn+F10/F11/F12 ), вебкамера.

Настройка сети

Самый простой способ на мой взгляд - это установка неофициального специального Ubuntu kernel, оптимизированного под Eee Pc.

Shortcuts

Шорткаты устанавливаются благодаря http://forum.eeeuser.com и его пользователю elmurato. Нужно скачать его скрипты и установить. К сожалению шорткаты начинают работать только после логина. Так что если вам надо отключить звук во время загрузки, у вас это получится только вставив наушники.

WebCam

BIOS. Onboard devices. WebCam Enabled.

Saturday, 31 May 2008

Проблемы с запуском графической части Ubuntu (gdm)

Проблема была в кратце такова, что при нормальной загрузке Ubuntu моментально подвисала, как только показывалось графическое окно login. В то же время, если сначала загрузиться в recovery mode, а потом запустить графическую оболочку (startx), то всё работало нормально.

Напрашивается вывод, что при recovery mode Ubuntu не загружает некоторые модули, которые возможно конфликтуют с gdm. Как это выяснить?

Прежде всего загружаемся в recovery mode и из-под roota выполняем команду sysvconfig Там весь список загружаемых модулей. Убираем на время gdm. Сохраняем, выходим. Теперь при нормальной загрузке, компьютер не будет виснуть и мы сможем посмотреть какие модули им загружены.

Теперь всё в той же root консоли набираем dmesg > /home/[ваш username]/failsafe.log что сохранит лог загрузки в файл.

Также устанавливаем хороший diff'ер apt-get install meld Теперь можем спокойно перезагрузиться в нормальном режиме.

Так как мы в самом начале отключили загрузку gdm, то после перезагрузки мы снова в консоли. Нужно залогиниться и выполнить аналогичную команду, чтоб записать лог загрузки. dmesg > /home/[ваш username]/normal.log

Осталось только сравнить эти два лога. Я использовал удобство gdm,- загрузился туда через recovery mode, сравнил через meld эти 2 файла (!! meld сравнивает посимвольно а не построчно, поэтому различия в начале строк, которые являются временем загрузки не сильно волновали !!). В файлах явно читались названия модулей подгружаемых при обычном старте и игнорируемых в recovery mode. У меня это были bluetooth и powernowd. Поэтому, снова запустив sysvconfig, отключил bluetooth, powernowd и powernowd.early, не забыл включить gdm и перезагрузился в нормальном режиме.

Теперь всё работает.

Thursday, 31 January 2008

Install Ruby Gem Postgres In Ubuntu Linux

Installing ruby gem postgres in Ubuntu linux
sudo gem install postgres
gives the next error
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
  ERROR: Failed to build gem native extension.

ruby extconf.rb ins postgres
extconf.rb:46: command not found: pg_config --includedir
extconf.rb:53: command not found: pg_config --libdir
checking for main() in -lpq... no

Can be solved by:

sudo apt-get install libpq-dev
sudo gem install postgres-pr