Archive for the ‘Ubuntu’ Category

searching by content in files, real example

May 29, 2011

Recently I’ve got a problem with finding some text, some content in my old emails.

I use Google account with this gmail. So I tried to find that text using gmail web search, but it was with no success. Also I have local mail client – I use Thunderbird – so I tried to find using its embedded search capabilities – but no success.

I was starting thinking that I never sent this mail or I have deleted it already.  Also.. I use Ubuntu as my desktop machine, and remembering my post about the searching by content in the files I opened my console in my home directory and type there such command: “grep -rn my_text_i_want_to_find .” and voilà – I got it.

So.. why gmail and thunderbird could not do it I don’t know it. So this is a real example of old-school approach of searching that works and able to help you.


installing ruby & rubyOnRails in ubuntu

March 5, 2011

Ubuntu 10.10, ruby 1.9.2, rubyonrails 3.0.x.

######### INSTALLING ##############

#First, let’s install all of the necessary tools and libraries:
apt-get install curl git-core build-essential zlib1g-dev libssl-dev libreadline5-dev

#Install ruby 1.9.2 using RVM. Refer to the official RVM instructions here. Make sure you have curl #and git installed (from above) and run this command:
bash < <( curl )

#Then add this line as the last line to your .bashrc:
source “$HOME/.rvm/scripts/rvm”

#Close your terminal and open a new one, then run the following to test your RVM’s installation:
rvm notes

#Next, you can begin ruby 1.9.2 installation by running:
rvm install 1.9.2

#The install will take up to several minutes and once it completes you have to set ruby 1.9.2 as the #default version:
rvm –default ruby-1.9.2

#Then you can test your new ruby install:ruby -v
#install railsgem install rails

#that’s all! (minimum settings)

######## GEM -PACKAGINGs #######

#RuvyGems – slike Maven repository or like apt-get in Ubuntu

# shows all gems (all plugins avaliable for RoR)
gem list –local
gem list –remote

#search by “STRING” in the remote repository
gem search STRING –remote

#do this just in case, and look at the output:
gem install rubygems-update

######### CREATING AND LAUNCH A NEW APP #########

i may recommend to use rubymine ide, but you should know how create your app in command line:

rails new YOUR_APP_PATH

rails server

#launch app
rails s
#or (if you want to set the port by yourself)
rails s –port 8080

#open your browser and type there – this is your aplication:

########### CHANGING DB for your app ###########

#i suppose you would like to work with mysql database instead of using default one (which is defined in your_app_path/config/database.yml )
so, in order to switch the db for your project, you should:

  1. edit tht file database.yml like this:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: myproject_development
    pool: 5
    username: root
    socket: /var/run/mysqld/mysqld.sock

    #do it for all databases not only for development one (if you wish)
    #by the way: Ruby on Rails recommends to create three databases
    1. myproject_development
    2. myproject_production
    3. myproject_test

  2. add some libs and gems.. for mysql support
    sudo apt-get install libmysqlclient-dev
    gem install mysql2
  3. add new line to your project’s folder
    to file: Gemfile
    line: gem ‘mysql2’
    #it means that you are going to use this module/gem in your project
  4. create the databases for your project
    cd your_app_path
    rake db:create

    #it will create 2 databases – for development and for tests

alt print screen in ubuntu

March 4, 2011

it seems it does not work from the box

so, in oder to fix that type the command

sudo sysctl -w kernel.sysrq=0

This will disable “SysRq” key, which use the Alt+PrtScn.

how to download a video from YouTube

December 17, 2010
D’habitude je télécharge un vidéo de YouTube à l’aide de une extension de FireFox. Mais ce n’est pas toujours belle décision, parce que il y a quelques-uns d’entre eux n’ont pas téléchargement. Alors, maintenant j’utilise Totem Vidéo Player qui est par défaut dans Ubuntu. Il y a un semple comme ce a l’air. Usually I download a video from Youtube using some Firefox plugin. But that does not work out sometimes. Some video is not downloadable. So, now i’m using Totem Video Player which is installed by default in Ubuntu. There is a sample how it looks like.

Comme vous pouvez voir, j’utilise ici la fonction de ‘glisser-déposer’ à le télécharger à mon Bureau. As you can see, here I’m using drug & drop to download ii to my desktop.

ubuntu is fun

December 6, 2010

Do like this:

sudo apt-get moo

or like this: Alt + F2 (to show the allocation launcher window), and then type there: free the fish and click Enter 🙂

mysql. making case insensible

November 1, 2010

in the file: /etc/mysql/mysqld/my.cnf, add lines:
lower-case-table-names = 1

then check:
$ mysql -u root -p
$  mysql> show variables like “%lower%”;

update .profile

October 30, 2010

If you want to reload environment variables without needing to do re-login, you may use this command:

source ~/.profile

how to get a pid of the process

October 20, 2010

Sometimes we should able to get pid of the process dynamically. For example we want to kill the process (kill -9 <PID>)  from some script, but we can’t know the pid of particular process, and knowing the name of the process is not enough also. For example if we have several java processes where ‘java’ is the name of the processes, we could use command like this ‘killall -9 java’, but it will kill all java processes.

In our example we want to delete jboss process. JBoss is a java program and has ‘java’ as a name of process.  So.. in order to get the PID of jboss process we could use command like this:

ps -Ao pid,command | grep java | sed ‘s/^[ ]*//’ | cut -d\  -f1

Here, as you can see, we use special command ‘sed’.
Here is small description how it might be used:

Ok. Now we want to kill this process. We could type something like this:

myvar=`ps -Ao pid,command | grep java | grep jboss | sed ‘s/^[ ]*//’ | cut -d\  -f1`;kill -9 $myvar

Yes, you can type this in single command line.

ssh -X option

October 11, 2010

Maybe not everybody knows about the ability to use -X option while connecting via ssh in the console. I will describe. For example if there is a task to deploy some web application (that uses 8080 port for http) to the remote server and ensure that it work ok there. And lets say the 8080 port opened only for some series of machines but not for yours, and you can not open your browser in your machine and check whether the application work ok or not.

So, in order to resolve our issue, we are connecting like this:
ssh -X user@ (you should use the ip of particular remote host here and real user of course).

Then when you are logged in, type in the console: nautilus and press enter. As a result you will able to see the graphical file manager. And from here you may launch graphical console and launch any applications, for example Firefox or use samba to connect to your machine… etc. So this gives us greater possibilities to use UI to work with files and applications on the remote hosts.

There is a picture how it might look like, here we use native Firefox on remote machine which renders on your machine in fact. My local machine here is Ubuntu, but remote is RH Linux.

Maybe it is not the best example but it is possible one.

the program to learn French verbs

October 3, 2010

There is a small program that helps learn – conjugate French words (verbs). You can find it in the Ubuntu (Linux) repositories.

%d bloggers like this: