Sunday, December 25, 2011

How to deploy with Mercurial aka HG on rails3.1

1. Install Phusion Passenger module (www.modrails.com/) on top of Apache2 or Nginx
2. Edit .hg/hgrc on the destination (production server).

[hooks]
incoming = hg update -C && RAILS_ENV=production rake db:migrate && bundle exec rake assets:precompile && touch tmp/restart.txt

(http://pastie.org/3073448)

Let's explain briefly rails aspects of [hooks].

RAILS_ENV=production rake db:migrate -- sets environment to production mode and migrates the database.

bundle exec rake assets:precompile -- precompiles scss (sass), coffescript (js) and image files from app/assets to the public/assets directory.

touch tmp/restart.txt -- sends Passenger command to restart the server.



Enjoy!

Sunday, September 4, 2011

How to solve: This Terminal Emulator is not functional because no 'bash' shell could be found in Aptana Studio 3

This Terminal Emulator is not functional because no 'bash' shell could be found.
Please correct the problem and restart the IDE.

Info


Let's see the Aptana's Studio 3 log file.

java.io.IOException: Cannot run program "/opt/Aptana Studio 3/plugins/com.aptana.terminal_3.0.0.1310755723/os/linux/x86/redtty"


Solution



chmod +x "/opt/Aptana Studio 3/plugins/com.aptana.terminal_3.0.0.1310755723/os/linux/x86/redtty"

Then File -> Restart

Tuesday, July 19, 2011

How to search for a particular word in SQLite database

I have written simple python script that looks through SQLite database
for any entry occurrence in any table in any column.
Here it is

If you have any questions, please leave your comment.

Sunday, July 17, 2011

How to build html-tables on the fly

Now we're going to discuss how to build html tables from JSON response.

First we need library that can easily handle JSON. For instance, JQuery.
Suppose, we have included core JQuery library.

Here is the htmltable.js
Now all that we need is just to include that htmltable.js file and load any JSON like that:

function dynamicTable(URL, id){
url = URL + '?id=' + id

$.getJSON(url, function(data) {
captions = {'code':'Code','descr':{'content':'Description','attr': 'style="width: 800px"'}}
html_table = build_table(data, captions);
$('#anyDivId').html(html_table);
});
}

Wednesday, July 6, 2011

How to install pysqlite (python sqlite binding interface) on Ubuntu Linux

First you need development libraries:

$ sudo apt-get install libsqlite3-dev

Then you have to download pysqlite files from http://code.google.com/p/pysqlite/
Next steps are usual: unpack and change dir

After that run (you should have gcc - GNU C compiler - of course):

$ python setup.py build

After compilation runs successfully you are able to install pysqlite with:

$ sudo python setup.py install

That's all

Tuesday, July 5, 2011

How to resize many images by extension at once (Linux, Unix)

First you need to install ImageMagick.

Then just change dir and type:

$ mogrify -resize 2048x1536 *.jpg

Where 2048x1536 is new size of all images with .jpg extension.