Blog

Rails: Flash Message Partial (self-hiding)

(Wed. June 8th 2o11, 11:00 pm)

For self -hiding Ruby on Rails 3 flash messages you can use the following in a partial which can be included within application layouts. (requires you are using jQuery)

<br /><div id="flash-banner"><br /><br /> "flash " + key.to_s, :id =&gt; key.to_s + "-message" %&gt;<br /> "text/javascript" do %&gt;<br />$('#').css('display', 'none');<br />$('#').slideDown().delay(1000).slideUp();<br /><br /><br /></div><br />

Rails: Killing a Rouge Webrick Server

If you have ever accidentally closed a terminal window which was running your Rails Webrick server and the server continued to run in the background but you need to kill it so you can restart a new instance you can do the following:

1. run the lsof command identifying port 3000 as the target to get the process ID of the rouge Webrick server

lsof -i:3000

2. then use the kill command plus the process ID you got from step 1 and your rouge will be taken care of.

kill process_id

Of course this is just one way to handle it, if anyone has a better way please comment and let the rest of us know. Thanks in advance!

HTML Special Characters

Latin-1 Entities
  No-break space = non-breaking space
¡ ¡ ¡ ¡ Inverted exclamation mark
¢ ¢ ¢ ¢ Cent sign
£ £ £ £ Pound sign
¤ ¤ ¤ ¤ Currency sign
¥ ¥ ¥ ¥ Yen sign = yuan sign
¦ ¦ ¦ ¦ Broken bar = broken vertical bar
§ § § § Section sign
¨ ¨ ¨ ¨ Diaeresis = spacing diaeresis
© © © © Copyright sign
ª ª ª ª Feminine ordinal indicator
« « « « Left double angle mark = left guillemet
¬ ¬ ¬ ¬ Not sign = discretionary hyphen
­ ­ ­ ­ Soft hyphen = discretionary hyphen
® ® ® ® Registered sign = registered trade mark sign
¯ ¯ ¯ ¯ Macron = overline = APL overbar
° ° ° ° Degree sign
± ± ± ± Plus-minus sign = plus-or-minus sign
² ² ² ² Superscript two = squared
³ ³ ³ ³ Superscript three = cubed
´ ´ ´ ´ Acute accent = spacing acute
µ µ µ µ Micro sign
Pilcrow sign = paragraph sign
· · · · Middle dot = Greek middle dot
¸ ¸ ¸ ¸ Cedilla = spacing cedilla
¹ ¹ ¹ ¹ Superscript one = superscript digit one
º º º º Masculine ordinal indicator
» » » » Right double angle mark = right guillemet
¼ ¼ ¼ ¼ fraction one quarter
½ ½ ½ ½ fraction one half
¾ ¾ ¾ ¾ fraction three quarters
¿ ¿ ¿ ¿ inverted (turned) question mark
À À À À Latin capital letter A with grave
Á Á Á Á Latin capital letter A with acute
    Latin capital letter A with circumflex
à à à à Latin capital letter A with tilde
Ä Ä Ä Ä Latin capital letter A with diaeresis
Å Å Å Å Latin capital letter A with ring
Æ Æ Æ Æ Latin capital ligature letter AE
Ç Ç Ç Ç Latin capital letter C with cedilla
È È È È Latin capital letter E with grave
É É É É Latin capital letter E with acute
Ê Ê Ê Ê Latin capital letter E with circumflex
Ë Ë Ë Ë Latin capital letter E with diaeresis
Ì Ì Ì Ì Latin capital letter I with grave
Í Í Í Í Latin capital letter I with acute
Î Î Î Î Latin capital letter I with circumflex
Ï Ï Ï Ï Latin capital letter I with diaeresis
Ð Ð Ð Ð Latin capital letter ETH
Ñ Ñ Ñ Ñ Latin capital letter N with tilde
Ò Ò Ò Ò Latin capital letter O with grave
Ó Ó Ó Ó Latin capital letter O with acute
Ô Ô Ô Ô Latin capital letter O with circumflex
Õ Õ Õ Õ Latin capital letter O with tilde
Ö Ö Ö Ö Latin capital letter O with diaeresis
× × × × multiplication sign
Ø Ø Ø Ø Latin capital letter O with slash
Ù Ù Ù Ù Latin capital letter U with grave
Ú Ú Ú Ú Latin capital letter U with acute
Û Û Û Û Latin capital letter U with circumflex
Ü Ü Ü Ü Latin capital letter U with diaeresis
Ý Ý Ý Ý Latin capital letter Y with acute
Þ Þ Þ Þ Latin capital letter THORN
ß ß ß ß Latin small letter sharp s = ess-zed
à à à à Latin small letter a with grave
á á á á Latin small letter a with acute
â â â â Latin small letter a with circumflex
ã ã ã ã Latin small letter a with tilde
ä ä ä ä Latin small letter a with diaeresis
å å å å Latin small letter a with ring
æ æ æ æ Latin small ligature letter ae
ç ç ç ç Latin small letter c with cedilla
è è è è Latin small letter e with grave
é é é é Latin small letter e with acute
ê ê ê ê Latin small letter e with circumflex
ë ë ë ë Latin small letter e with diaeresis
ì ì ì ì Latin small letter i with grave
í í í í Latin small letter i with acute
î î î î Latin small letter i with circumflex
ï ï ï ï Latin small letter i with diaeresis
ð ð ð ð Latin small letter eth
ñ ñ ñ ñ Latin small letter n with tilde
ò ò ò ò Latin small letter o with grave
ó ó ó ó Latin small letter o with acute
ô ô ô ô Latin small letter o with circumflex
õ õ õ õ Latin small letter o with tilde
ö ö ö ö Latin small letter o with diaeresis
÷ ÷ ÷ ÷ division sign
ø ø ø ø Latin small letter o with slash
ù ù ù ù Latin small letter u with grave
ú ú ú ú Latin small letter u with acute
û û û û Latin small letter u with circumflex
ü ü ü ü Latin small letter u with diaeresis
ý ý ý ý Latin small letter y with acute
þ þ þ þ Latin small letter thorn
ÿ ÿ ÿ ÿ Latin small letter y with diaeresis
Symbols and Greek Letters
ƒ ƒ ƒ ƒ Latin small f with hook = florin
Α Α Α Α Greek capital letter alpha
Β Β Β Β Greek capital letter beta
Γ Γ Γ Γ Greek capital letter gamma
Δ Δ Δ Δ Greek capital letter delta
Ε Ε Ε Ε Greek capital letter epsilon
Ζ Ζ Ζ Ζ Greek capital letter zeta
Η Η Η Η Greek capital letter eta
Θ Θ Θ Θ Greek capital letter theta
Ι Ι Ι Ι Greek capital letter iota
Κ Κ Κ Κ Greek capital letter kappa
Λ Λ Λ Λ Greek capital letter lambda
Μ Μ Μ Μ Greek capital letter mu
Ν Ν Ν Ν Greek capital letter nu
Ξ Ξ Ξ Ξ Greek capital letter xi
Ο Ο Ο Ο Greek capital letter omicron
Π Π Π Π Greek capital letter pi
Ρ Ρ Ρ Ρ Greek capital letter rho
Σ Σ Σ Σ Greek capital letter sigma
Τ Τ Τ Τ Greek capital letter tau
Υ Υ Υ Υ Greek capital letter upsilon
Φ Φ Φ Φ Greek capital letter phi
Χ Χ Χ Χ Greek capital letter chi
Ψ Ψ Ψ Ψ Greek capital letter psi
Ω Ω Ω Ω Greek capital letter omega
α α α α Greek small letter alpha
β β β β Greek small letter beta
γ γ γ γ Greek small letter gamma
δ δ δ δ Greek small letter delta
ε ε ε ε Greek small letter epsilon
ζ ζ ζ ζ Greek small letter zeta
η η η η Greek small letter eta
θ θ θ θ Greek small letter theta
ι ι ι ι Greek small letter iota
κ κ κ κ Greek small letter kappa
λ λ λ λ Greek small letter lambda
μ μ μ μ Greek small letter mu
ν ν ν ν Greek small letter nu
ξ ξ ξ ξ Greek small letter xi
ο ο ο ο Greek small letter omicron
π π π π Greek small letter pi
ρ ρ ρ ρ Greek small letter rho
ς ς ς ς Greek small letter final sigma
σ σ σ σ Greek small letter sigma
τ τ τ τ Greek small letter tau
υ υ υ υ Greek small letter upsilon
φ φ φ φ Greek small letter phi
χ χ χ χ Greek small letter chi
ψ ψ ψ ψ Greek small letter psi
ω ω ω ω Greek small letter omega
ϑ ϑ ϑ ϑ Greek small letter theta symbol
ϒ ϒ ϒ ϒ Greek upsilon with hook symbol
ϖ ϖ ϖ ϖ Greek pi symbol
bullet = black small circle
horizontal ellipsis = three dot leader
prime = minutes = feet
double prime = seconds = inches
overline = spacing overscore
fraction slash
script capital P = power set = Weierstrass p
blackletter capital I = imaginary part
blackletter capital R = real part symbol
trade mark sign
alef symbol = first transfinite cardinal
leftwards arrow
upwards arrow
rightwards arrow
downwards arrow
left right arrow
down arrow with leftwards corner = CR
leftwards double arrow
upwards double arrow
rightwards double arrow
downwards double arrow
left right double arrow
for all
partial differential
there exists
empty set = null set = diameter
nabla = backward difference
element of
not an element of
contains as member
n-ary product = product sign
n-ary sumation
minus sign
asterisk operator
square root = radical sign
proportional to
infinity
angle
logical and = wedge
logical or = vee
intersection = cap
union = cup
integral
therefore
tilde operator = varies with = similar to
approximately equal to
almost equal to = asymptotic to
not equal to
identical to
less-than or equal to
greater-than or equal to
subset of
superset of
not a subset of
subset of or equal to
superset of or equal to
circled plus = direct sum
circled times = vector product
up tack = orthogonal to = perpendicular
dot operator
left ceiling = APL upstile
right ceiling
left floor = APL downstile
right floor
left-pointing angle bracket = bra
right-pointing angle bracket = ket
lozenge
black spade suit
black club suit = shamrock
black heart suit = valentine
black diamond suit
Other special characters
" quotation mark = APL quote
& & & & ampersand
< < < < less-than sign
> > > > greater-than sign
Œ Œ Œ Œ Latin capital ligature OE
œ œ œ œ Latin small ligature oe
Š Š Š Š Latin capital letter S with caron
š š š š Latin small letter s with caron
Ÿ Ÿ Ÿ Ÿ Latin capital letter Y with diaeresis
ˆ ˆ ˆ ˆ modifier letter circumflex accent
˜ ˜ ˜ ˜ small tilde
en space
em space
thin space
zero width non-joiner
zero width joiner
left-to-right mark
right-to-left mark
en dash
em dash
left single quotation mark
right single quotation mark
single low-9 quotation mark
left double quotation mark
right double quotation mark
double low-9 quotation mark
dagger
double dagger
per mille sign
single left-pointing angle quotation mark
single right-pointing angle quotation mark
euro sign

Dummy/Fake SMTP/Mail Trap for Development Purposes

This post started out as a question on StackOverflow.com (found here). I have moved over to Linux Mint 10 for all of my Ruby and Ruby on Rails application development. I have found this flavour of Linux to be the most pleasant for my purposes. But I ran into a bit of a problem when I first moved over form Windows.

Issue: On windows I had more than one option when it came to a dummy/fake SMTP/Mail trap which I could use to catch and examine the emails generated and sent out by the applications on which I was working. Extremely useful when testing account registration and email activation 🙂 But on Linux all I found were posts about setting up a full blown SMTP server and then connecting a mail client to it and pulling the emails locally. PUKE, GAG,VOMIT way too much work for me and I am really not interested in becoming a professional mail server administrator.

Solution: After millions of hours searching for a decent solution I ram across a Ruby Gem called MailTrap, oh my saviour, I can’t even begin to tell you how much I love this GEM, it makes my life so much easier.

[sudo] gem install mailtrap

Then don’t forget to setup your development environment file with the following entries

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:domain => “mydomain.net”,
:address => “localhost”,
:port => 2525,
}
config.action_mailer.default_url_options = { :host => ‘localhost:2525’ }

Then simply run the gem application in a terminal window and you will see each of the mail messages as they come in or you can view them in the log file that is created.

mailtrap run

RVM Application Specific Gemset

Step 1: Setup your Ruby 1.9.2-head

$ rvm 1.9.2-head
WARN: ruby ruby-1.9.2-head is not installed.To install do: ‘rvm install ruby-1.9.2-head’

Step 2: Install the utilities need to build the head

$ sudo apt-get install bison
$ sudo apt-get install autoconf

Step 3: Install your Ruby 1.9.2-head

$ rvm install ruby-1.9.2-head

Step 4: Create your new GemSet

$ rvm gemset create corerivalry

RVM, Ruby, Rails on Linux Mint

Step 1: First we need to install all the required libraries

$ sudo apt-get install curl git-core build-essential zlib1g-dev libssl-dev libreadline5-dev

Step 2: Install RVM

$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

Step 3: mint 10 does not have a .bashrc file so one needs to be added and then RVM specific lines added

$ sudo touch .bashrc
$ sudo gedit .bashrc
(Add line to .bashrc file)
if [[ -s "$HOME/.rvm/scripts/rvm" ]]  ; then source "$HOME/.rvm/scripts/rvm" ; fi

Step 4: close the current terminal and open a new one in order to load the new commands

Step 5: verify RVM has been installed by running you should get back a description of the application written by the author

$ rvm notes

Step 6: now you can install the ruby version of your choice, I am using 1.9.2 so it is compatible with Rails 3

$ rvm install 1.9.2

Step 7: once installed you will need to set the default ruby version to be used by RVM

$ rvm --default ruby-1.9.2

Step 8: verify that the version you selected is now accessible via the standard ruby command

$ ruby -v

Step 9: then use the gem command to install the rails version of your choice

$ gem install rails

Step 10: install MySQL

$ sudo apt-get install libmysql-ruby libmysqlclient-dev
$ gem install mysql2