Tuesday, May 8, 2012

RVM + Ruby + Rails Installation In Ubuntu

Step1: Install GCC and Other Tools
You need the C compiler and the Make utility. So this is the first package called build-essential that should be installed. To install run the following in your terminal

$ sudo apt-get install build-essential


Step2: Install Curl
 RVM will need curl to download files. should be installed. Run the following



$ sudo apt-get install curl

Step3: Install Libraries
You need the following libraries;
  • readline, which lets you edit lines of text in bash or IRB
  • zlib, which Rubygems will need to function
  • OpenSSL
  • LibXML
So run the following to install

$ sudo apt-get install zlib1g-dev libreadline-dev libssl-dev libxml2-dev

Step4: Install RVM
Now that you're all set up, install RVM itself. To install run

$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
 Append the following line to your ~/.bashrc file.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM

And then reload your bash environment (or close the terminal window and open a new one).

$ source ~/.bashrc



Step5: Test your RVM
If installation was successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output 'rvm is a function' as shown below.

$ type rvm | head -n 1


Step6: Install Ruby
To install ruby 1.9.3 run the following command.

$ rvm install 1.9.3 

The last part of the command above is the version of ruby, so if you want to install other version of ruby just change that e.g, 1.8.7, 1.9.2 e.t.c


Step6: Install Rails
To install rails run the following command

$ gem install rails

Step6: You are done
Though you are done I would recommend you use gemsets to manage your gems.
For more informations about this visit https://rvm.io/gemsets/. Fill free to drop a comment if you need any assistance.

References;
Welcome to Ruby Community:)
Banta

How To Enable Hibernation On Ubuntu 12.04

Step1: You need to check whether hibernation works in your comp. Run the following command in your terminal to test.

$ sudo pm-hibernate

If you are able to hibernate and startup your machine then you can go to the next sptep.

Step2: Run the following command in your terminal to start editing.

$ sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

Fill the editor with this


[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes


Then save and exit.


Step3: Restart your machine. You should hibernation.:)

Tuesday, April 3, 2012

Wanna Play Canvas Rider On Firefox?

[url=http://canvasrider.com/tracks/58766]Antarctic slopes by lolz666[/url]

How To Install Gambas

I'm going to show you how to install gambus 3 on ubuntu. For other Linux distributors please click here.



Step1
Install the following by typing the following on your terminal:

sudo apt-get install build-essential autoconf libbz2-dev libfbclient2
libmysqlclient-dev unixodbc-dev libpq-dev libsqlite0-dev libsqlite3-dev 
libgtk2.0-dev libldap2-dev libcurl4-gnutls-dev libgtkglext1-dev 
libpcre3-dev libsdl-sound1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev 
libsage-dev libxml2-dev libxslt1-dev libbonobo2-dev libcos4-dev 
libomniorb4-dev librsvg2-dev libpoppler-dev libpoppler-glib-dev 
libasound2-dev libesd0-dev libdirectfb-dev libaa1-dev libxtst-dev 
libffi-dev firebird2.1-dev libqt4-dev libglew1.5-dev libimlib2-dev 
libv4l-dev libsdl-ttf2.0-dev libgnome-keyring-dev libgdk-pixbuf2.0-dev 
linux-libc-devfff


Step2
Download gambus3 from their site here. If you had gambas2 installed and you want to remove it before going on with installing v3 click here. Extract the file then do the following:

$ cd 
$ ./reconf-all

Step3
Once this script is finished, you can run the common commands to compile and install a program:

$ ./configure
$ make
$ su
# make install


This should leave you with a working version of Gambas in /usr/local/bin .. so if you now type in "gambas3" from the terminal session, it should start your nice new IDE.


Monday, April 2, 2012

How To Uninstall Gambas?

If you had already installed GAMBAS you must deinstall it, and remove some trace do the following in your terminal:

cd /usr/local/bin
rm gambas*
rm gbx2
cd /usr/bin
rm gambas*
cd /usr/share
rm -R gambas
cd /usr/lib
rm -R gambas
cd /usr/share/doc
rm -R gambas
rm -R gambas*
cd /usr/share/man/man1
rm gambas*
cd /usr/share/pixmaps
rm gambas*
cd /usr/share/lintian/overrides
rm gambas*
cd /usr/share/applications
rm gambas.desktop


As well remove in the local users directory the file ./gambas

cd $HOME
rm .gambasectory

Sunday, April 1, 2012

Gambas

What is Gambas?

Gambas is a dialect of the BASIC programming language as well as the integrated development environment that accompanies it. It is designed to run on Linux and other Unix-like computer operating systems.

Gambas meaans "Gambas Almost Means Basic".

Gambas is included in a number of Linux distributions' repositories, such as Debian's, Fedora's, Mandriva Linux's and Ubuntu's. There is a Windows version of Gambas which can run under the Cygwin environment, although this version is significantly less tested than its Linux counterparts and is command line only; coLinux and derivatives have also been used.


Wednesday, February 15, 2012

Codility prefix_set Solution 100%

A non-empty zero-indexed array A consisting of N integers is given. The first covering prefix of array A is the smallest integer P such that 0≤P
For example, the first covering prefix of the following 5−element array A:

A[0] = 2  A[1] = 2  A[2] = 1
A[3] = 0  A[4] = 1
 
is 3, because sequence [ A[0], A[1], A[2], A[3] ] equal to [2, 2, 1, 0], contains all values that occur in array A.
Write a function
           class Solution { public int ps(int[] A); }
that, given a zero-indexed non-empty array A consisting of N integers, returns the first covering prefix of A.
Assume that:
  • N is an integer within the range [1..1,000,000];
  • each element of array A is an integer within the range [0..N−1].
For example, given array A such that
A[0] = 2  A[1] = 2  A[2] = 1
A[3] = 0  A[4] = 1
the function should return 3, as explained above.
Complexity:

  • expected worst-case time complexity is O(N);
  • expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).
Solution:

import java.util.HashSet;
import java.util.Set;

class Solution {
  public int ps ( int[] A ) {
    Set set = new HashSet();
        int index =-1;

        for(int i=0;i

Codility Demo Solution 100%

I'm about to take a codility test and I'm somehow nervous. So the solution to the demo problem: -

A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such that 0 ≤ P < N and the sum of elements of lower indices is equal to the sum of elements of higher indices,

i.e. A[0] + A[1] + ... + A[P−1] = A[P+1] + ... + A[N−2] + A[N−1].

Sum of zero elements is assumed to be equal to 0.
This can happen if P = 0 or if P = N−1.

For example, consider the following array A consisting of N = 7
elements: A[0] = -7 A[1] = 1 A[2] = 5 A[3] = 2 A[4] = -4 A[5] = 3 A[6] = 0 P = 3 is an equilibrium index of this array,
because A[0] + A[1] + A[2] = A[4] + A[5] + A[6]. P = 6 is also an equilibrium index, because: A[0] + A[1] + A[2] + A[3] + A[4] + A[5] = 0 and there are no elements with indices greater than 6.

P = 7 is not an equilibrium index, because it does not fulfill the condition 0 ≤ P < N. Write a function class Solution { public int equi(int[] A); } that, given a zero-indexed array A consisting of N integers, returns any of its equilibrium indices.
The function should return −1 if no equilibrium index exists. Assume that: N is an integer within the range [0..10,000,000]; each element of array A is an integer within the range [−2,147,483,648..2,147,483,647].
 For example, given array A such that A[0] = -7 A[1] = 1 A[2] = 5 A[3] = 2 A[4] = -4 A[5] = 3 A[6] = 0 the function may return 3 or 6, as explained above. Complexity: expected worst-case time complexity is O(N); expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).  

Solution in Java

// you can also use imports, for example:
// import java.math.*;
class Solution {
  public int equi ( int[] A ) {
    long sum = 0;
    int i = 0;
    
    for (i = 0; i < A.length; i++) {
        sum += (long) A[i];
    }
    
    long sum_left = 0;
    for (i = 0; i < A.length; i++) {
        long sum_right = sum - sum_left - (long) A[i];
        
        if (sum_left == sum_right) {
            return i;
        }
        sum_left += (long) A[i];
    }
    return -1;// write your code here
  }
}

Tuesday, May 8, 2012

RVM + Ruby + Rails Installation In Ubuntu

Step1: Install GCC and Other Tools
You need the C compiler and the Make utility. So this is the first package called build-essential that should be installed. To install run the following in your terminal

$ sudo apt-get install build-essential


Step2: Install Curl
 RVM will need curl to download files. should be installed. Run the following



$ sudo apt-get install curl

Step3: Install Libraries
You need the following libraries;
  • readline, which lets you edit lines of text in bash or IRB
  • zlib, which Rubygems will need to function
  • OpenSSL
  • LibXML
So run the following to install

$ sudo apt-get install zlib1g-dev libreadline-dev libssl-dev libxml2-dev

Step4: Install RVM
Now that you're all set up, install RVM itself. To install run

$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
 Append the following line to your ~/.bashrc file.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM

And then reload your bash environment (or close the terminal window and open a new one).

$ source ~/.bashrc



Step5: Test your RVM
If installation was successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output 'rvm is a function' as shown below.

$ type rvm | head -n 1


Step6: Install Ruby
To install ruby 1.9.3 run the following command.

$ rvm install 1.9.3 

The last part of the command above is the version of ruby, so if you want to install other version of ruby just change that e.g, 1.8.7, 1.9.2 e.t.c


Step6: Install Rails
To install rails run the following command

$ gem install rails

Step6: You are done
Though you are done I would recommend you use gemsets to manage your gems.
For more informations about this visit https://rvm.io/gemsets/. Fill free to drop a comment if you need any assistance.

References;
Welcome to Ruby Community:)
Banta

How To Enable Hibernation On Ubuntu 12.04

Step1: You need to check whether hibernation works in your comp. Run the following command in your terminal to test.

$ sudo pm-hibernate

If you are able to hibernate and startup your machine then you can go to the next sptep.

Step2: Run the following command in your terminal to start editing.

$ sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

Fill the editor with this


[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes


Then save and exit.


Step3: Restart your machine. You should hibernation.:)

Tuesday, April 3, 2012

Wanna Play Canvas Rider On Firefox?

[url=http://canvasrider.com/tracks/58766]Antarctic slopes by lolz666[/url]

How To Install Gambas

I'm going to show you how to install gambus 3 on ubuntu. For other Linux distributors please click here.



Step1
Install the following by typing the following on your terminal:

sudo apt-get install build-essential autoconf libbz2-dev libfbclient2
libmysqlclient-dev unixodbc-dev libpq-dev libsqlite0-dev libsqlite3-dev 
libgtk2.0-dev libldap2-dev libcurl4-gnutls-dev libgtkglext1-dev 
libpcre3-dev libsdl-sound1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev 
libsage-dev libxml2-dev libxslt1-dev libbonobo2-dev libcos4-dev 
libomniorb4-dev librsvg2-dev libpoppler-dev libpoppler-glib-dev 
libasound2-dev libesd0-dev libdirectfb-dev libaa1-dev libxtst-dev 
libffi-dev firebird2.1-dev libqt4-dev libglew1.5-dev libimlib2-dev 
libv4l-dev libsdl-ttf2.0-dev libgnome-keyring-dev libgdk-pixbuf2.0-dev 
linux-libc-devfff


Step2
Download gambus3 from their site here. If you had gambas2 installed and you want to remove it before going on with installing v3 click here. Extract the file then do the following:

$ cd 
$ ./reconf-all

Step3
Once this script is finished, you can run the common commands to compile and install a program:

$ ./configure
$ make
$ su
# make install


This should leave you with a working version of Gambas in /usr/local/bin .. so if you now type in "gambas3" from the terminal session, it should start your nice new IDE.


Monday, April 2, 2012

How To Uninstall Gambas?

If you had already installed GAMBAS you must deinstall it, and remove some trace do the following in your terminal:

cd /usr/local/bin
rm gambas*
rm gbx2
cd /usr/bin
rm gambas*
cd /usr/share
rm -R gambas
cd /usr/lib
rm -R gambas
cd /usr/share/doc
rm -R gambas
rm -R gambas*
cd /usr/share/man/man1
rm gambas*
cd /usr/share/pixmaps
rm gambas*
cd /usr/share/lintian/overrides
rm gambas*
cd /usr/share/applications
rm gambas.desktop


As well remove in the local users directory the file ./gambas

cd $HOME
rm .gambasectory

Sunday, April 1, 2012

Gambas

What is Gambas?

Gambas is a dialect of the BASIC programming language as well as the integrated development environment that accompanies it. It is designed to run on Linux and other Unix-like computer operating systems.

Gambas meaans "Gambas Almost Means Basic".

Gambas is included in a number of Linux distributions' repositories, such as Debian's, Fedora's, Mandriva Linux's and Ubuntu's. There is a Windows version of Gambas which can run under the Cygwin environment, although this version is significantly less tested than its Linux counterparts and is command line only; coLinux and derivatives have also been used.


Wednesday, February 15, 2012

Codility prefix_set Solution 100%

A non-empty zero-indexed array A consisting of N integers is given. The first covering prefix of array A is the smallest integer P such that 0≤P
For example, the first covering prefix of the following 5−element array A:

A[0] = 2  A[1] = 2  A[2] = 1
A[3] = 0  A[4] = 1
 
is 3, because sequence [ A[0], A[1], A[2], A[3] ] equal to [2, 2, 1, 0], contains all values that occur in array A.
Write a function
           class Solution { public int ps(int[] A); }
that, given a zero-indexed non-empty array A consisting of N integers, returns the first covering prefix of A.
Assume that:
  • N is an integer within the range [1..1,000,000];
  • each element of array A is an integer within the range [0..N−1].
For example, given array A such that
A[0] = 2  A[1] = 2  A[2] = 1
A[3] = 0  A[4] = 1
the function should return 3, as explained above.
Complexity:

  • expected worst-case time complexity is O(N);
  • expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).
Solution:

import java.util.HashSet;
import java.util.Set;

class Solution {
  public int ps ( int[] A ) {
    Set set = new HashSet();
        int index =-1;

        for(int i=0;i

Codility Demo Solution 100%

I'm about to take a codility test and I'm somehow nervous. So the solution to the demo problem: -

A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such that 0 ≤ P < N and the sum of elements of lower indices is equal to the sum of elements of higher indices,

i.e. A[0] + A[1] + ... + A[P−1] = A[P+1] + ... + A[N−2] + A[N−1].

Sum of zero elements is assumed to be equal to 0.
This can happen if P = 0 or if P = N−1.

For example, consider the following array A consisting of N = 7
elements: A[0] = -7 A[1] = 1 A[2] = 5 A[3] = 2 A[4] = -4 A[5] = 3 A[6] = 0 P = 3 is an equilibrium index of this array,
because A[0] + A[1] + A[2] = A[4] + A[5] + A[6]. P = 6 is also an equilibrium index, because: A[0] + A[1] + A[2] + A[3] + A[4] + A[5] = 0 and there are no elements with indices greater than 6.

P = 7 is not an equilibrium index, because it does not fulfill the condition 0 ≤ P < N. Write a function class Solution { public int equi(int[] A); } that, given a zero-indexed array A consisting of N integers, returns any of its equilibrium indices.
The function should return −1 if no equilibrium index exists. Assume that: N is an integer within the range [0..10,000,000]; each element of array A is an integer within the range [−2,147,483,648..2,147,483,647].
 For example, given array A such that A[0] = -7 A[1] = 1 A[2] = 5 A[3] = 2 A[4] = -4 A[5] = 3 A[6] = 0 the function may return 3 or 6, as explained above. Complexity: expected worst-case time complexity is O(N); expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).  

Solution in Java

// you can also use imports, for example:
// import java.math.*;
class Solution {
  public int equi ( int[] A ) {
    long sum = 0;
    int i = 0;
    
    for (i = 0; i < A.length; i++) {
        sum += (long) A[i];
    }
    
    long sum_left = 0;
    for (i = 0; i < A.length; i++) {
        long sum_right = sum - sum_left - (long) A[i];
        
        if (sum_left == sum_right) {
            return i;
        }
        sum_left += (long) A[i];
    }
    return -1;// write your code here
  }
}