Editing a form in nested_form gem

This is a very very naive and simple thing but I quite lost my time on this so I thought might be helpful.

Recently I was using the ‘nested_form’ gem by the great Ryan Bates (https://github.com/ryanb/nested_form). The form to create a new form works like a real gem without any effort.

Now, when I clicked on ‘edit’ link, it created some issues as the nested models didnt come.

I had a simple thing like each question has many answers. When I created a question, I added 5 answers to it but when I edited the question, no answers were visible.

The simple solution for this would be that the <% f.fields_for :answers do |an| %> line in your form would be without an equal to sign so just add it.

Thus, it looks like

<%= f.fields_for :answers do |an| %>

Thats all and it works like a charm!

Hope it helps.

Fixing Ubuntu GPG BADSIG error

Recently, I faced a error while updating my Ubuntu system.

When I ran “sudo apt-get update”,

it gave me the followinf error message:


W: GPG error: http://archive.canonical.com intrepid Release: The following signatures were invalid: BADSIG 40976EAF437D05B5 Ubuntu Archive Automatic Signing Key


The way I fixed it was:


$ sudo -i

# apt-get clean

# cd /var/lib/apt

# mv lists lists.old

# mkdir -p lists/partial

# apt-get clean

# apt-get update


Hope it helps. !!

Western european special characters and how to enter them from your keyboard

HTML Name Code HTML Number Code Glyph MacOS Windows Description
&lsquo; option+] Alt+0145 left single quote
&rsquo; shift+option+] Alt+0146 right single quote
&sbquo; single low-9 quote
&ldquo; option+[ Alt+0147 left double quote
&rdquo; shift+option+[ Alt+0148 right double quote
&bdquo; shift+option+w double low-9 quote
&dagger; option+t Alt+0134 dagger
&Dagger; shift+option+7 Alt+0135 double dagger
option+; horizontal ellipsis
&permil; shift+option+r Alt+0137 per mill sign
&lsaquo; shift+option+3 Alt+0139 single left-pointing angle quote
&rsaquo; shift+option+4 Alt+0155 single right-pointing angle quote
&spades; black spade suit
&clubs; black club suit
&hearts; black heart suit
&diams; black diamond suit
&oline; overline, = spacing overscore
&larr; leftward arrow
&uarr; upward arrow
&rarr; rightward arrow
&darr; downward arrow
&trade; option+2 Alt+0153 trademark sign
&quot; " double quotation mark
&amp; & & ampersand
&lt; < < less-than sign
&gt; > > greater-than sign
[ [ left square bracket
] ] right square bracket
&ndash; option+hyphen Alt+0150 en dash
&mdash; shift+option+hyphen Alt+0151 em dash
&nbsp;   Alt+0160 nonbreaking space
&iexcl; ¡ ¡ option+1 Alt+0161 inverted exclamation
&cent; ¢ ¢ option+4 Alt+0162 cent sign
&pound; £ £ option+3 Alt+0163 pound sterling
&curren; ¤ ¤ Alt+0164 general currency sign
&yen; ¥ ¥ option+y Alt+0165 yen sign
&brvbar; or &brkbar; ¦ ¦ Alt+0166 broken vertical bar
&sect; § § option+6 Alt+0167 section sign
&uml; or &die; ¨ ¨ shift+option+u Alt+0168 umlaut
&copy; © © option+g Alt+0169 copyright
&ordf; ª ª option+9 Alt+0170 feminine ordinal
&laquo; « « option+\ Alt+0171 left angle quote
&not; ¬ ¬ option+l Alt+0172 not sign
&shy; ­ ­ Alt+0173 soft hyphen
&reg; ® ® option+r Alt+0174 registered trademark
&macr; or &hibar; ¯ ¯ Alt+0175 macron accent
&deg; ° ° shift+option+8 Alt+0176 degree sign
&plusmn; ± ± shift+option+= Alt+0177 plus or minus
&sup2; ² ² Alt+0178 superscript two
&sup3; ³ ³ Alt+0179 superscript three
&acute; ´ ´ shift+option+e Alt+0180 acute accent
&micro; µ µ option+m Alt+0181 micro sign
&para; option+7 Alt+0182 paragraph sign
&middot; · · shift+option+9 Alt+0183 middle dot
&cedil; ¸ ¸ shift+option+z Alt+0184 cedilla
&sup1; ¹ ¹ Alt+0185 superscript one
&ordm; º º option+0 Alt+0186 masculine ordinal
&raquo; » » shift+option+\ Alt+0187 right angle quote
&frac14; ¼ ¼ Alt+0188 one-fourth
&frac12; ½ ½ Alt+0189 one-half
&frac34; ¾ ¾ Alt+0190 three-fourths
&iquest; ¿ ¿ shift+option+? Alt+0191 inverted question mark
&Agrave; À À option+` A Alt+0192 uppercase A, grave accent
&Aacute; Á Á option+e A Alt+0193 uppercase A, acute accent
&Acirc; Â Â option+i A Alt+0194 uppercase A, circumflex accent
&Atilde; Ã Ã option+n A Alt+0195 uppercase A, tilde
&Auml; Ä Ä option+u A Alt+0196 uppercase A, umlaut
&Aring; Å Å shift+option+a Alt+0197 uppercase A, ring
&AElig; Æ Æ shift+option+’ Alt+0198 uppercase AE
&Ccedil; Ç Ç shift+option+c Alt+0199 uppercase C, cedilla
&Egrave; È È option+` E Alt+0200 uppercase E, grave accent
&Eacute; É É option+e E Alt+0201 uppercase E, acute accent
&Ecirc; Ê Ê option+i E Alt+0202 uppercase E, circumflex accent
&Euml; Ë Ë option+u E Alt+0203 uppercase E, umlaut
&Igrave; Ì Ì option+` I Alt+0204 uppercase I, grave accent
&Iacute; Í Í option+e I Alt+0205 uppercase I, acute accent
&Icirc; Î Î option+i I Alt+0206 uppercase I, circumflex accent
&Iuml; Ï Ï option+u I Alt+0207 uppercase I, umlaut
&ETH; Ð Ð Alt+0208 uppercase Eth, Icelandic
&Ntilde; Ñ Ñ option+n N Alt+0209 uppercase N, tilde
&Ograve; Ò Ò option+` O Alt+0210 uppercase O, grave accent
&Oacute; Ó Ó option+e O Alt+0211 uppercase O, acute accent
&Ocirc; Ô Ô option+i O Alt+0212 uppercase O, circumflex accent
&Otilde; Õ Õ option+n O Alt+0213 uppercase O, tilde
&Ouml; Ö Ö option+u O Alt+0214 uppercase O, umlaut
&times; × × Alt+0215 multiplication sign
&Oslash; Ø Ø shift+option+o Alt+0216 uppercase O, slash
&Ugrave; Ù Ù option+` U Alt+0217 uppercase U, grave accent
&Uacute; Ú Ú option+e U Alt+0218 uppercase U, acute accent
&Ucirc; Û Û option+i U Alt+0219 uppercase U, circumflex accent
&Uuml; Ü Ü option+u U Alt+0220 uppercase U, umlaut
&Yacute; Ý Ý Alt+0221 uppercase Y, acute accent
&THORN; Þ Þ Alt+0222 uppercase THORN, Icelandic
&szlig; ß ß option+s Alt+0223 lowercase sharps, German
&agrave; à à option+` a Alt+0224 lowercase a, grave accent
&aacute; á á option+e a Alt+0225 lowercase a, acute accent
&acirc; â â option+i a Alt+0226 lowercase a, circumflex accent
&atilde; ã ã option+n a Alt+0227 lowercase a, tilde
&auml; ä ä option+u a Alt+0228 lowercase a, umlaut
&aring; å å option+a Alt+0229 lowercase a, ring
&aelig; æ æ option+’ Alt+0230 lowercase ae
&ccedil; ç ç option+c Alt+0231 lowercase c, cedilla
&egrave; è è option+` e Alt+0232 lowercase e, grave accent
&eacute; é é option+e e Alt+0233 lowercase e, acute accent
&ecirc; ê ê option+i e Alt+0234 lowercase e, circumflex accent
&euml; ë ë option+u e Alt+0235 lowercase e, umlaut
&igrave; ì ì option+` i Alt+0236 lowercase i, grave accent
&iacute; í í option+e i Alt+0237 lowercase i, acute accent
&icirc; î î option+i i Alt+0238 lowercase i, circumflex accent
&iuml; ï ï option+u i Alt+0239 lowercase i, umlaut
&eth; ð ð Alt+0240 lowercase eth, Icelandic
&ntilde; ñ ñ option+n n Alt+0241 lowercase n, tilde
&ograve; ò ò option+` o Alt+0242 lowercase o, grave accent
&oacute; ó ó option+e o Alt+0243 lowercase o, acute accent
&ocirc; ô ô option+i o Alt+0244 lowercase o, circumflex accent
&otilde; õ õ option+n o Alt+0245 lowercase o, tilde
&ouml; ö ö option+u o Alt+0246 lowercase o, umlaut
&divide; ÷ ÷ Alt+0247 division sign
&oslash; ø ø option+o Alt+0248 lowercase o, slash
&ugrave; ù ù option+` u Alt+0249 lowercase u, grave accent
&uacute; ú ú option+e u Alt+0250 lowercase u, acute accent
&ucirc; û û option+i u Alt+0251 lowercase u, circumflex accent
&uuml; ü ü option+u u Alt+0252 lowercase u, umlaut
&yacute; ý ý Alt+0253 lowercase y, acute accent
&thorn; þ þ Alt+0254 lowercase thorn, Icelandic
&yuml; ÿ ÿ option+u y Alt+0255 lowercase y, umlaut

Conditional Compilation in C

C provides a very useful and interesting feature called “conditional Compilation

the general structure for doing it:

#ifdef macroname

statement 1;
statement 2;
statement 3;
statement 4;

here if macroname has been #defined then the 4 statements will be compiled otherwise not.

There are 3 scenarios where I see application of this feature:

-> To “comment out” obselete lines of code. It may happen that a program undergoes a change for some reasons.
Here we may not want to delete the old code but add new code.
In this scenario, we can include the old and new code in ifdef block and control the compilation using a single #define statement.


void main()

#ifdef OLD
statement 1;
statement 2;
statement 3;
statement 4;



here , if we define thee macro “OLD” then old code is compiled otherwise, the new code is compiled.

->The other (more sophisticated) use of this feature can be to make the programs more portable.
Thus, we can make use of this feature and make a program work on two completely different computers.


void main()
#ifdef INTEL
code for intel PC
code for motorola PC
code common for both.


This code is pretty self explanatory.
If you want your code to run on INTEL we just need to define a macro.

->A third possible scenario is defining of custom functions.
Lets say we define a function called “my_sample_function()” in a file “file1.h”
Also, “file1.h” is included in “file2.h

If we include both the files, compiler will throw an error saying “multiple declaration of my_sample_function()

To overcome this problem, we can use the following way:

/* file1.h */

#ifndef _file
#define _file
/*some code */

Here when file1.h gets included first time, compiler knows that macro _file is not defined. Thus it gets defined and the rest of code is compiled.
Next time, since the macro stands defines, the function does not get compiled and thus there is no error.

NOTE: #ifndef is exactly opposite of #ifdef


Conditional compilation can also be achieved using #if ,#else #endif statements.

#if is used to evaluate whether a expression evaluated to nonzero value or not.

it is used in the same way as above:



void main(){

if TEST<=5

statment 1;


statement 2;



Ways to include a file in C

There are two ways of including a file in C using #include statement:

#include “filename”

This command would look for the file in the current directory as well as the specified list of directories as mentioned in the include search path that might have been setup.


#include <filename>

This command would look for the file on the specified list of directories only.




Why not to use Strings in Cucumber

Cucumber allows you to define step definitions using strings instead of regular expressions.

This might seem simpler at first, but it has other problems, which I’ll illustrate with an example.

Here is a step definition that uses a plain string.

Given “I have 100 in my Account” do


We couldn’t write $100 here, because the $ has a special meaning when you define step definitions with strings.

Any $ signs—including any letter or number following it—will be interpreted as an argument, .

This step definition uses an argument:

Given “I have $amount in my Account” do |amount|



This step definition would match both of the following Gherkin steps:

Given I have 100 in my Account

Given I have $100 in my Account


In the first case, the Step Definition’s amount argument would have the value “100”. In the second case it would have the value “$100”. If our Step Definition expects a string with only digits, this can be problematic. We have no way to enforce a consistent way to write Gherkin steps, and the step definitions have to anticipate many kinds of input.


This is why using strings instead of regular expressions is not as advantageous as you might think. They give far less control over what gets matched and what arguments a step definition can receive.

HappyNess !!

Happy Moment: you solve your first sum of calculus without copying !
Next Moment :Teacher says this was very easy..any1 can do it.

Happy Moment: you see the word “passed” while seeing your result.
Next Moment: Dad says…..you scored very less….

Happy Moment: you finally complete education.
Next Moment: you are asked questions about jobs !

Happy Moment: you get your first offer letter.
Next moment: parents say your cousin got 1 lac more than you.

Happy Moment : you cook first time.
Next Moment : you are told “Tune kitchen ka kya haal kar diya ??”

Happy Moment: some1 says I love you to you.
Next Moment : He/she puts conditions for you. !!

Happy Moment : you bring sweets from your first salary.
Next Moment: they say taste is not good!

Happy Moment: You get your first visiting card.
Next Moment: No one is interested except you.

Happy Moment : you complete your project !

Next Moment: Tester says “It breaks !”


Happy Moment: you get in a running train!

Next Moment: you see there is no place to sit.!!
Happy Moment: you see your kids face for the first time.
Next moment: hospital presents you with a bill !

Happy moment: you finally leave the world.
Next Moment: people fight over your money in front of your dead body !

Happyness my friends never last long !
Its the memories of these happy moments that we must cherish !!