Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, April 14, 2008

Converting Gedit into Textmate


Yes, so lately I have been developing using the Ruby on Rails framework a lot. To my irony there ain't much choice nor there exist any really really good IDE or editor for Rails on Ubuntu(or rather Linux in general). You could use VIM or Emacs but for some reason that I cant understand I choose not to use them.

My favorite text editor on ubuntu was Gedit. Although by default you don't get a hell lot of features in it but the best I liked was tabbed browsing. I guess thats a common thing in most Linux GUI based applications. Ok so this is what your Gedit would look like:
Hmm.. so lets quickly start the process of changing Gedit into something close to textmate:
1) Lets quickly download Jose's Gedit bundle.
2) Edit the mime types file and add the below mentioned lines

sudo nano /etc/mime.types
text/x-ruby-source                           rhtml html.erb
text/x-eruby rjs
text/x-yaml yml

3) Update the new extensions mime types
sudo update-mime-database /usr/share/mime


4) Copy the x-rhtml to the directory /usr/share/mime/packages

sudo cp gmate2/mime/x-rhtml.xml /usr/share/mime/packages
5) Copy extensions ruby.lang, rhtml.lang and rjs.lang the directory /usr/share/gtksourceview-2.0/language-specs
sudo cp gmate2/langs/*.lang /usr/share/gtksourceview-2.0/language-specs
6) Update plugins
cp -R gmate2/plugins/* ~/.gnome2/gedit/plugins/
7) Copy the snippets (cuts)
cp -R gmate2/snippets/* ~/.gnome2/gedit/snippets/
8) Copy the colors

cp gmate2/styles/Rubycius.xml ~/.gnome2/gedit/styles/
9) Remove a directory of your gnome settings
rm -Rf /tmp/gconfd-warlock

where warlock is your username.

10) Open the Gedit and on the menu: Edit> Preferences> Plugins tab and:
  • Gemini (May auto complete parentheses, quotation marks, brackets, etc.)
  • Snippets
  • Snap Open (the key combination of CTRL + ALT + O opens a dialog where you can find the files you want)
11) Choose the theme "Rubycius" on the menu: Edit> Preferences tab "Fonts and Colors"

12) Finally, if you want in the menu: Edit> Preferences tab "View" can: Show line numbers, and current line Highlight Show right margin.

If for some reason the formating dont appear then quickly go to the terminal and hit
sudo update-mime-database /usr/share/mime

If everything is done right you should get this sort of output(text highlighting) for your files you open:


=================================================
||My FREE services||

ParkingWHOIS is now not only a domain parking lookup, but now also has reviews on Parking Companies.
=================================================

Saturday, March 15, 2008

Setup GIT for Rails


GIT is a popular version control system designed to handle very large projects with speed and efficiency; it is used mainly for various open source projects, most notably the Linux kernel. Git falls in the category of distributed source code management tools, similar to e.g. GNU Arch or Monotone (or BitKeeper in the proprietary world). Every Git working directory is a full-fledged repository with full revision tracking capabilities, not dependent on network access or a central server. Basically it Rocks.

I am on a Linux box so this is what I need to install GIT

sudo apt-get install git-tk git-svn git-email git-doc git-cvs git-core git-arch

once this is done you can test the GIT setup by typing GIT in the terminal. You should typically get this output.

So now your GIT is up and ready to fire. Now navigate to your rails project folder. Follow these steps to create your repository:
  1. Initialize a new git repo
  2. Create a .gitignore for files git should ignore while committing
  3. Default values for a .gitignore
  4. In case you don't see a /log /vendor /tmp | note use sudo(super user) if these directories are already created but are empty
  5. Commit your files in the repo | again do this from the home of the project
  6. You can check the status of the repo

// Initialize a new git repo
git init
//Create a .gitignore for files git should ignore while committing
touch .gitignore
//Default vaules for a .gitignore
DS_Store
log/*.log
tmp/**/*
config/database.yml
//In case you dont see a /log /vendor /tmp | note use sudo if these directories are already created but are empty
touch /log .gitignore /vendor .gitignore /tmp .gitignore
//Adding your files for the repo | do this from the home of the project
git add .
//Commit your files in the repo | again do this from the home of the project
git commit -a -m "Some message here... mostly the reason to commit"
//You can check the status of the repo
git status

And that pretty much covers the basics. Till the next time.... peace

=================================================
||My FREE services||

ParkingWHOIS is now not only a domain parking lookup, but now also has reviews on Parking Companies.
=================================================

Sunday, December 16, 2007

Common rails validations



A rather short post, this one if focused on few validations in rails that I often use. In rails you could do a lot of validations, as they are very simple to handle. Because of the well structured and separated MVC architecture all you need to do is write you validations for the database in our model. Actually as a matter of fact you could also write them as a library and call its methods. The ones below aim to do just that. They use regular expressions, in case you are confused with what that is do read up.

Validating an Email Address

validates_format_of(:email,
:with => /^([^@s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i,
:on => :create,
:message=>"has an invalid format")

Validating URLs

validates_format_of :url, :with => /^(https?://)?([^/]+)(/.+)?$/i

# OR

validates_format_of :url, :with => /^(ftp|https?)://((?:[-a-z0-9]+.)+[a-z]{2,})/

Validating IP addresses

validates_format_of :ip, :with => /^(d{1,3}.d{1,3}.d{1,3}.d{1,3})?$/

=================================================
||My FREE services||

ParkingWHOIS is now not only a domain parking lookup, but now also has reviews on Parking Companies.
=================================================


Tuesday, December 4, 2007

Installing Rails on uBuntu 7.10 Gusty Gibbons


So I wanted to install Ruby on Rails on my new linux box. And really thats not tough, this post just guides you to do the same. Actually I feel it is 80% easier to setup your linux box for any programming language than a windows COMPUTER. I might be wrong cause I used Windows for about a decade and then its a little more than one year since I have been using uBuntu (DUH!! a linux distro for the ones that didnt know) and I am already in love with it. One year and it still hasn't crashed. I can go on and on about my love for uBuntu but I think I will stop here. Ohh BTW uBuntu 7.10 (or uBuntu Gusty Gibbons has launched). It is sooooo light and awesome looking that my mom also is telling me to install it on her laptop. Truly linux for human beings. But I think I will let her laptop be a dual boot with XP and uBuntu; It will help me test my web apps.

Coming back to the main topic of discussion, I need to install Rails on uBuntu (actually works well for debian too). So here are few basic steps you might want to review:
1) Make sure all the build essentials are present on your Linux box. If not then quickly get into the terminal and hit

sudo apt-get install build-essential

2) Next you need to install ruby ri and rdocs so hit
sudo apt-get install ruby ri rdoc

3) Now you would want to download the latest versions of RubyGems; you could do that from http://rubyonrails.org/down or hit
sudo wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz

4) Uncompress and extract the file by
tar -xvzf rubygems-0.9.0.tgz

5) Go into that folder by
cd rubygems-0.9.0

6) execute the setup.rb file to setup RubyGems
sudo ruby setup.rb

7) Use RubyGems to install Rails
sudo gem install rails --include-dependencies

8) If the previous step gave you an error about SSL then install the Open SSL library for ruby
sudo apt-get install libopenssl-ruby


And you are ready to go!!! Lets test the Rails setup by creating a demo project and running it (remember you are still in the terminal)
$ rails testapp
$ cd testapp
$ ruby script/server

/testapp$ ./script/server
=> Booting WEBrick…
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-12-07 05:28:37] INFO WEBrick 1.3.1
[2006-12-07 05:28:37] INFO ruby 1.8.4 (2005-12-24) [i486-linux]
[2006-12-07 05:28:37] INFO WEBrick::HTTPServer#start: pid=6687 port=3000



You’ll notice that the server is listening on port 3000. Open up a browser, and go to http://localhost:3000. Ok this is it for this article hope you are successful in setting up Rails on your Linux box and I wish your app gets as famous as David's. Peace.








=================================================
||My FREE services||

Find out more information about domain parking at ParkingWHOIS
=================================================