wrong number of arguments (1 for 0) | Rails | Facepalm

I am working on a simple web application to help out dieudonne and came across a seemingly random error on the rails stack while trying to build a simple email functionality. My thought process was to scaffold a “message” model and have a “send” function in the controller that would then parse the mail content using LiquidTemplating and send out the email with a delayed job process.

 

Well, all fine and dandy till I hit this error,

__define_callbacks

activesupport (4.0.2) lib/active_support/callbacks.rb
364365366367368369370371372373374
      # if it was not yet defined.
      # This generated method plays caching role.
      def __define_callbacks(kind, object) #:nodoc:
        name = __callback_runner_name(kind)
        unless object.respond_to?(name, true)
          str = object.send("_#{kind}_callbacks").compile
          class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
            def #{name}() #{str} end
            protected :#{name}
          RUBY_EVAL
end


There is no information about this out there and no one on the interwebs seems to be talking about that particular line:
str = object.send("_#{kind}_callbacks").compile

which is where unicorn says I am going wrong. Now, I know I have done no changes in the rails stack and thought maybe it was the model name and maybe I couldnt create a "message" model. So I made a "communication" model and scaffolded it. No dice. 

A week later, when I decided to give it another go, I realized that I ve been inadvertently overriding the "send" method from the rails Controller class. Rename the function "send" to something else and voila, things are back to normal.

facepalm.

I wish unicorn was better at telling me the issue started at the controller and not at some point in the rails stack. oh well.

No, DO NOT start deprecating your CSS

This is in reply to this post on medium that was recently shared by Sidebar on one of their recent daily newsletters. I found this post so ridiculous that I felt compelled to write this follow up post.

I want you to go to the last web page you have developed and view the source. How many programming languages did you have to write? If you’re like me, you probably have some HTML, CSS, JavaScript or Node, and PHP in there. You may be able to count the languages on one hand, but that doesn’t leave many fingers left on that hand for typing more code.

It doesnt matter how many languages you used. What matters is wether you used them right and wether the end product was what you wanted it to be. It matters how efficient that end product was and how usable it is. It matters if the code written was maintainable and readable. It doesnt matter how many languages you used, it only matters how efficiently those languages were used.

Freeing hand space is critical, so it’s important that we try to remove one of the languages in our stack. HTML can only be replaced by XML, which defeats the purpose of saving space, and web pages on modern browsers cannot run without Node or PHP. Through process of elimination, we are left with finding an alternative for CSS. Fortunately, that is possible with Node.

Hold on, wait, is the author actually saying there is no other language out there that can serve up web pages other than node and PHP? and why is is so critical to remove a language in the stack? Also, if it is so critical, why not remove PHP or Node and handle the logic in one of those (very small subset of languages available)?

 

Using Node Instead of CSS

Replacing CSS with Node is easy and actually a lot more intuitive and whitespace-free. All you have to do is open your .js file and type in the instructions for changing the style of elements. For example, take a look at the following CSS for changing the color and padding of a paragraph with id “gulp”:

#gulp { 
    color : #0000ff;
    padding : 10px; 
}

This CSS takes up 4 lines, and at least 13 spaces. In node, we’ll change the style for the same paragraph:

document.getElementById(‘gulp’).style.color=‘#00f’;
document.getElementById(‘gulp’).style.padding=‘10px’;

This Node code takes up only 2 lines and there are 0 spaces. Essentially, we are saving lines, spaces, and files (delete your .css documents!).

1. This is vanilla JavaScript and not necessarily node.

2. If 2 lines are better than 4, the css can be written in one line

#gulp{color:#0000ff;padding:10px;}

now, by the same argument, css became a better choice.

3. The JS written is ineffecient. The author is traversing the DOM twice to target the same element. A better way to write that would have been to cache the element in a variable and do the style updates on the variable.

var gulp = document.getElementById(‘gulp’);

gulp.style.color=’#00f’;

gulp.style.padding=’10px’;

Either the author chose to not do this out of ignorance or to make a point. I dont see the point. The problem with this style is that it is not maintainable. CSS is much more DRYer than this proposed JS method. It easier to maintain and on top of it, it has all the hardware accelerated goodness that comes with natively supported languages.

The Future of CSS

Just like the blink and marquee tags, it will only be a matter of time until browsers stop supporting CSS, so the sooner you start using HTML5 to style your pages, the longer your projects will last in the future.

It’s time to take back our fingers and whitespace and stop using so many languages to perform the same tasks.

This is when I kind of realize that this whole post is satire (at least I hope it is, for the love of all things web!). I should probably just give up on all languages and write my web pages in assembly (makes things way faster, no?).

In conclusion, those of you who are new to web development and took this article seriously, UNLEARN any coding patterns you might have learnt through this post. I believe it is meant to be satire. For those who saw it coming from the beginning, touche.

 

 

 

 

 

Kerbal Space Program (KSP) : How to transfer fuel after docking

So I ve been looking for an answer to this for a while now, I was docked and didnt know what to do after.

Tried right-clicking different fuel tanks, no dice. Finally found the answer somewhere.

 

alt + right click on the tanks you want to see the transfer happen between. This will give you the “in” and “out” buttons.

Steel City Ruby Conf’12 : My first Ruby Conf – Awesome!!!

So I am just getting some much needed rest after attending the first Steel City Ruby Conf (and my first ruby conf). I have to say it was definitely one of the best conferences I ve been to, it was more of a well rounded conference than a technical conference! The theme of the conference seemed to be more “meet each other and listen to people in-between” than the normal “we have a bunch of people talking to ya” thing. The interesting part is that it opened up channels for people to communicate instead of just sitting around listening to people talk. The other cool thing was that we were encouraged to sit at different tables and lunch with a different group of people every time.

I had the pleasure of lunching with Joe O’Brien ‏ (@objo) , Jim Weirich ‏ @jimweirich (the inventor of Rake), Greg Malcolm ‏ @GregMalcolm and a whole bunch of awesomly interesting people! The full list of people who attended is here. I also met some awesome people from 4moms who build interesting products for parents and it aint as expensive as other baby stuff like they pointed out. Also in attendance was Jack of square. And Skill Bonsai raffled out 3 books, I won one. I am now the proud owner of

I am a relatively new to ruby and the community, though I ve deployed ruby apps before. I am primarily a PHP developer, I still love PHP and I am growing to love Ruby as well. The conference was a huge success, and I am enjoying my time in Pittsburgh!

Fixed Bug: Applications Disappear after Over the Air Install – iPhone App Development

I have been working with a couple of iPhone apps recently and in all cases I ve had to set up an Over the Air install client to distribute the apps to all the dev devices. My friend, Ulf wrote a ruby cms (hosted on github) for this very purpose (Thanks Much!). Here is a bug that seems to have baffled some people and never been an issue for some people.

Bug: The app installs but as soon as it does, the icon disappears from the screen.

This can be irritating, understandably.

Issue: The app id doesn’t match the provisioning profile.

Fix: Found Here

It turns out to be that the bundle-identifier in the app-info.plist file did not match the adhoc provisioning profile identifier. This property has to match the APP ID in the provisioning portal that you created the profile with.
i.e. My APP ID = com.TheApp.*
WRONG:
bundle-identifier
com.SomeOtherName.Whatever
CORRECT:
bundle-identifier
com.TheApp.TheAppName
Also, make sure that you replace ‘TheAppName’ with the same value as ‘Product Name’ in your project + target settings.

Building multiple buildings from a map inside maya

Tools needed:

Adobe Photoshop
Autodesk Maya
Google Maps
Google Earth

Lets get started

For this post, i am using the map data from NYC’s gis website. Here is the link http://gis.nyc.gov/doitt/nycitymap/

The first thing you need to do is decide the area on the map you are going to work on. I am going to start small, just a block from downtown brooklyn for now. My ultimate motive for doing this is to publish it inside BetaVille, the project i am working for as a 3D Artist right now. So, here is the block. All you need is a screenshot of the block.

Screenshot for building the buildings ground up.

 

 

Now, Open this up in Photoshop. We are going to use the pen tool to pen on top of the edges of the buildings.

Open it up in photoshop

Select the Pen Tool

Pen on top of the building edges

Export the paths to illustrator

Export Options