Thursday, December 01, 2011

Deadlines


The best ideas needs time!!!

Thursday, November 17, 2011

Setting kernel's SHMMAX and SHMALL parameters (Installing Postgresql)

Between the common issues that the developers ought pass is the correct installation of the database, worth noting that some databases are easier than others, but in this case i'll talk about a particular issue of postgres.

Usually when we will start our postgres server, we use the follow command

pg_ctl start -D /installation_directory

the installation directory, outgth to have a file called postgresql.conf

if your system is not configured with acceptable parameters to SHMMAX and SHMALL the before command will display an error like this:

FATAL: could not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(key=5432001, size=16498688, 03600).
HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter. You can either reduce the request size or reconfigure the kernel with larger SHMMAX. To reduce the request size (currently 16498688 bytes), reduce PostgreSQL's shared_buffers parameter (currently 1536) and/or its max_connections parameter (currently 104).
If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the request size or reconfiguring SHMMIN is called for.
The PostgreSQL documentation contains more information about shared memory configuration.

in order to fix this, we have to configure these parameters correctly, to do this we have to execute the following commands.

Brayans-MacBook:~ brayancastrop$ sudo sysctl -w kern.sysv.shmmax=1073741824
kern.sysv.shmmax: 4194304 -> 1073741824
Brayans-MacBook:~ brayancastrop$ sudo sysctl -w kern.sysv.shmall=1073741824
kern.sysv.shmall: 1024 -> 1073741824

And that is it. now start your server

pg_ctl start -D /installation_directory

And go ahead!!!

Wednesday, November 09, 2011

Sending emails from local machine with Rails and Mac

From a long time ago I've ever had this problem, we can do this configuring our application file using smtp services like example "google", but it's really pretty easy.

To do this we only need follow two simple steps...

1. Configure your development enviroment file to use as delivery method :sendmail as follow

config.action_mailer.delivery_method = :sendmail

2. Start your smtp server that is already installed with Mac OSX Leopard or Lion in a console as follow

sudo postfix start

note: to see the log run "sudo tail -f /var/log/mail.log"

Too Easy!!!

Friday, August 12, 2011

Paperclip Resizing Options

Paperclip is intended as an easy file attachment library for ActiveRecord. The intent behind it was to keep setup as easy as possible and to treat files as much like other attributes as possible. This means they aren't saved to their final locations on disk, nor are they deleted if set to nil, until ActiveRecord::Base#save is called. It manages validations based on size and presence, if required. It can transform its assigned image into thumbnails if needed, and the prerequisites are as simple as installing ImageMagick (which, for most modern Unix-based systems, is as easy as installing the right packages). Attached files are saved to the filesystem and referenced in the browser by an easily understandable specification, which has sensible and useful defaults.
You can see the Github Repository through the link below

Paperclip GitHub Page


Resizing Options

The link below give us a lot of technical info about the options for resizing through ImageMagick

Complete list of ImageMagick options


But how can we use this options through Paperclip?

Paperclip has a wiki page giving us a few examples about how-to use it

https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation

For example:

Having a user model with an atached photo with some thumbnails (thumb, small, medium and others); I can resize it's dimensions using flags like "#", ">" or "^" and others

But how can we apply this to our styles?

We can use this for:

- fixed width and/or height

It can be used like below:
...
has_attached_file :photo,
  :styles => {
  :tiny => "100x100",            # fixed width and height
  :thumb => "100>x100", # resize to a fixed width if original height if greather than specified
                                                   # dimension and fixed height
  :small => "200x200>",   # fixed width and resize to a fixed height if original height i greather than
                                                   # specified dimension
  :medium => "200 "200x200<" # fixed width and resize to a fixed heigth if original height i less
                                                            # than specified dimension
}
...

- fixed width and/or proportional height It can be used like below:
...
has_attached_file :photo, :styles => {
  :small => "100",       # fixed width and proportional height
  :medium => "x100" # proportional width and fixed height
}
...

For more details about the geometry argument ("widthxheigth - 100x100") and these options see the link below

http://www.imagemagick.org/script/command-line-processing.php#geometry

Saturday, July 09, 2011

Social Media and Google+

Now Google give us a new way to promote your web apps in the Social Media World through the plus button.

Google+ Button