The Truth About Design Patterns

Marc Clifton

  1. Design patterns are a response to solving the entanglement nightmare that OOD, while not creating, made more complex.
  2. While the formalization of the patterns was in some ways useful, the implementation often results in over-complexity and misapplication, especially by inexperienced programmers.
  3. Experienced programmers were already implementing decent ways to disentangle non-OO and OO code, so really, I think very little was gained by formalizing patterns. If anything, it made things worse for experienced developers who had to go in and fix the insanity of bad pattern application by less experienced developers.

And apparently (and sad to say), there is much agreement in the community regarding points 2 & 3.

View original post

Developing Rails apps with SSL

Dough, mud and penguins

I’m working on some federated authentication (single sign-on) for 3rd-party applications and thought to use Ruby on Rails as a simple way to demo and develop the principles.

This is Rails, so it’s not entirely straightforward(*) but manageable on a Linux host.

In development mode, the default Webrick server does not support SSL, but a decent alternative is thin (https://github.com/macournoyer/thin) which also requires eventmachine.

To use thin with SSL we need to generate a self-signed certificate,

$ openssl req -newkey rsa:2048 -nodes -keyout neopir.key -x509 -days 365 -out neopir.crt Generating a 2048 bit RSA private key .....................+++ ..........................................+++ writing new private key to 'neopir.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank…

View original post 140 more words

Common git screwups and solutions

Ruby on Rails Blog

I was looking to learn a bit more about the parts of git I’ve not ventured into yet. What better way that looking the most common ways people screw them up and how to fix the resulting problems! Here’s a short list, compiled from my own experience and issues I’ve come across on the Internet.

I wrote the wrong thing in a commit message

If the commit hasn’t been push you can do the following, which will allow you to edit the message on the most recent commit:

git commit --amend

How can I undo the last commit?

You can use git reset e.g.:

git reset --hard HEAD~1

HEAD~1 means HEAD-1 commit. It should be noted that this is the nuclear option, and any changes you made will be discarded. If you want to keep your changes in the working tree use:

git reset --soft HEAD~1

If you’ve already published…

View original post 593 more words

What the Heck is Shadow DOM?

Dimitri Glazkov

If you build Web sites, you probably use Javascript libraries. If so, you are probably grateful to the nameless heroes whomaketheselibrariesnot suck.

One common problem these brave soldiers of the Web have to face is encapsulation. You know, one of them turtles on which the Object-Oriented Programming foundation sits, upon which stands most of the modern software engineering. How do you create that boundary between the code that you wrote and the code that will consume it?

With the exception of SVG (more on that later), today’s Web platform offers only one built-in mechanism to isolate one chunk of code from another — and it ain’t pretty. Yup, I am talking about iframes. For most encapsulation needs, frames are too heavy and restrictive.

What do you mean I must put each of my custom buttons in a separate iframe? What kind of insane…

View original post 1,301 more words

How to find index of records rendered by a partial with collection in Rails

Web::Framework.find_by_name "Ruby On Rails"

Using render partial with collection how to find the index of the records?

Somewhere I found that someone is commented like,
“It seems this is an undocumented feature of rails.”

Anyway we can find this by using ‘recordName_counter’.

Render a partial with collection


= render :partial = > "person", :collection => @winners
Name: = person.name 

In Partial write


  Rank: = person_counter + 1
  Name: = person.name 

Result


Rank: 1 Name: Peter
Rank: 2 Name: Paul
Rank: 3 Name: Mary

View original post

How to use Workling in Rails to increase the speed of the request processing

Renu's Blog

In ruby on rails application, if your request is taking too much time to process, you can make some part of the code to run in background.

For example,

In my application , I am sending notifications to owner,watch listers and trackers of a post, if there is any activity on the post. So when someone comments on the post, people will be getting notifications. I am using delayed jobs to generate notifications. But the problem here is inserts into delayed jobs. Whenever I comment on a post, all the inserts into the delayed job table takes long time, hence the response is coming too late.

My CommentsController

class CommentsController < ApplicationController

  def comment
   @comment = Comment.new(params[:comment])
   @comment.save
   @comment.send_messages
  end
end

To make the inserts into delayed jobs in the background, I used Workling. Implementing Workling is very simple.

1. Install the Workling plugin

script/plugin install git://github.com/purzelrakete/workling.git

2. Create the…

View original post 55 more words

Selecting Indian States in Rails

Ruby on Rails Blog

Just last week I coded a miracle Rails app. I say miracle because there was no client pressure. I had never seen like it. Though it was my friend, a client is a client, he must be stupid. Ones who are not, are not clients. Finishing ecommerce application less than a week made no sense to me, and I did it. That’s stupid.

Okay there was stage when I had to put a select box for selecting Indian states. I searched and found this excellent gem called carmen. I included it in gem file and I was able to put a select box for Indian states using this code

Well, the above code is in haml. However newly formed Telengana hasn’t reflected yet.

View original post