Rails Development

21 Jun, 2009

Your new referent story : Our Iceberg is melting

Posted by: philippe In: Book

I would say if you join our team your first action should be  :

gem install ouricebergismelting

A simple fable to explain you a complex issue  : How can I make successfully changes in my company ?

Just read it !

Here is the publisher’s presentation :

Our Iceberg Is Melting is a simple fable about doing well in an ever-changing world. Based on the award-winning work of Harvard’s John Kotter, it is a story that has been used to help thousands of people and organizations.

The fable is about a penguin colony in Antarctica. A group of beautiful emperor penguins live as they have for many years. Then one curious bird discovers a potentially devastating problem threatening their home and pretty much no one listens to him.

The characters in the story, Fred, Alice, Louis, Buddy, the Professor, and NoNo, are like people we recognize — even ourselves. Their tale is one of resistance to change and heroic action, seemingly intractable obstacles and the most clever tactics for dealing with those obstacles. It’s a story that is occurring in different forms all around us today — but the penguins handle the very real challenges a great deal better than most of us.

Our Iceberg Is Melting is based on pioneering work that shows how Eight Steps produce needed change in any sort of group. It’s a story that can be enjoyed by anyone while at the same time providing invaluable guidance for a world that just keeps moving faster and faster.

. Keep an eye on your business

1. High informative dashboard.
Key Performance Indicators (KPI) are financial and non-financial measures or metrics used to help an organization define and evaluate how successful it is.
Peppercan real-time Dashboards provide you with business intelligence across all areas of your company. The Dashboard offers instant snapshots of KPI, such as new sales orders, monthly calls, or past performance. Use your time analyzing and acting on your key data, not gathering it. Keep being informed of what happens in every project you are involved and actions from your partners.

2. Project management
Successful project management requires proper planning, organization of tasks, and the establishment of priorities and deadlines. In order to effectively manage projects from concept to conclusion, project managers need immediate access to key information to ensure the project remains on track and within budget.

Peppercan helps project managers with the execution and management of each phase of the project by enabling the efficient management of time, resources and project cost. Be aware of your project milestones to avoid large delays and cost growing up.

18 Dec, 2008

Marketing Emails in CRM

Posted by: Francois In: Peppercan

For those already familiar with our CRM, here is a little update on what’s coming next in the application.

We’re happy to announce the Marketing Emails module should be available early next year! It will feature several useful tools to broadcast emails, send newsletters, …

  • Creation of lists of people ( from the CRM or not )
Creation of people list
List of subscribers
  • Creation and edition of emails with the integrated editor. Templates can be created and selected to keep the same look and feel accross all email communication. Emails can be automatically sent on a specific date or “x days after subscription”, so that subscribers will receive emails on a regular basis. Once you have added them to the list, the system handle everything, there is nothing to worry about!
Creation and edition of html emails
Creation and edition of html emails
  • Still under heavy development, but to be released at the same time: A classic “Broadcast” system, which will allow users to create a temporary list of contacts and send them an email right away.

I will post more updates as we make progres on this!

07 Oct, 2008

Select box is slow

Posted by: philippe In: Rails

When you remark that is difficult to select a value from a select box, check if there is no label tag around the select tag…

Generating reports often means you’ll have to choose a period of time for those reports. It’s a pretty slow process and I just finished creating a way of making it a lot faster for common dates. Here’s how to do it!

Note that it uses the “Calendar-only date_select” I explained in this article with the advanced date format: http://www.safecoms.com/blog/2008/09/a-simple-calendar-only-date_select/
Some minor tweaks might be necessary if you’re using a standard installation of ActiveCalendar date_select.

1. Create a partial that will contain your shortcuts. As in the previous article, I created it in the views/layouts folder.
Mine contains Yesterday, Today, Last week, This week, Last month and This month.
- from_field is the id of the field which contains the start date
- to_field is obviously the id of the field which contains the end date of the period.

 <span class="link" 
onclick="set_date_shortcut
('<%=from_field%>', 
'<%=to_field%>', 
'<%=Date.today.to_time.advance(:days => -1).strftime("%Y/%m/%d")%>', 
'<%=Date.today.to_time.strftime("%Y/%m/%d")%>'
)">
Yesterday</span> | 
 
<span class="link" 
onclick="set_date_shortcut
('<%=from_field%>', 
'<%=to_field%>', 
'<%=Date.today.to_time.strftime("%Y/%m/%d")%>', 
'<%=Date.today.to_time.advance(:days => 1).strftime("%Y/%m/%d")%>'
)">
Today</span> |
 
<span class="link" 
onclick="set_date_shortcut
('<%=from_field%>', 
'<%=to_field%>', 
'<%=Time.now.at_beginning_of_week.advance(:weeks => -1).strftime("%Y/%m/%d")%>', 
'<%=Time.now.at_beginning_of_week.strftime("%Y/%m/%d")%>'
)">
Last week</span> |
 
<span class="link" 
onclick="set_date_shortcut
('<%=from_field%>', 
'<%=to_field%>', 
'<%=Time.now.at_beginning_of_week.strftime("%Y/%m/%d")%>', 
'<%=Time.now.at_beginning_of_week.advance(:weeks => 1).strftime("%Y/%m/%d")%>'
)">
This week</span> |
 
<span class="link" 
onclick="set_date_shortcut
('<%=from_field%>', 
'<%=to_field%>', 
'<%=Time.now.at_beginning_of_month.advance(:months => -1).strftime("%Y/%m/%d")%>', 
'<%=Time.now.at_beginning_of_month.strftime("%Y/%m/%d")%>'
)">
Last month</span> |
 
<span class="link" 
onclick="set_date_shortcut
('<%=from_field%>', 
'<%=to_field%>', 
'<%=Time.now.at_beginning_of_month.strftime("%Y/%m/%d")%>', 
'<%=Time.now.at_beginning_of_month.advance(:months => 1).strftime("%Y/%m/%d")%>'
)">
This month</span> ]

2. Add the “set_date_shortcut” function to your javascript (application.js):

function set_date_shortcut(div_from, div_to, value_from, value_to)
{
    var elmt = document.getElementById(div_from);
    elmt.value = value_from;
    elmt.onchange();
    elmt = document.getElementById(div_to);
     elmt.value = value_to;
     elmt.onchange();
}

Note the elmt.onchange(); call. This is necessary because the value the user actually sees is in a div and the value sent to the application is in a hidden field. The hidden field, which is updated by the javascript, has an onchange() trigger that updates the div. Without this manual call, the onchange() never happens.

Now, simply call your partial wherever you need it:

<%= render :partial => "layouts/dates_shortcut", :locals => { :from_field => "FROM_FIELD", :to_field => "TO_FIELD"} %>

Changing “FROM_FIELD” and “TO_FIELD” to your fields’ ids. That’s all!

Yesterday-Today-... shortcuts for easy period selection

Yesterday-Today-... shortcuts for easy period selection

04 Sep, 2008

Simple select box for numbers (with default)

Posted by: Francois In: Rails

Here’s one of those little tricks that can turn into a huge waste of time if you don’t know them:
How to make a simple select box with numbers that will return the value selected by the user.

<%= select_tag :amount, "#{@some_amount}"+options_for_select((1..30).collect {|x| [x, x] }, :amount) %>

And, a little extra: The same with a default selected value:

<%= select_tag :amount, "#{@some_amount}"+options_for_select((1..30).collect {|x| [x, x] }, :amount) %>

04 Sep, 2008

Google Chrome

Posted by: Francois In: Uncategorized

Some of you may already know it, many probably dont… Google recently released their own browser!

It’s called “Chrome”, it’s still a beta version, it does not have hundreds of new features… So what does it have?

It’s open source… Ok, well that’s nice but not super exciting! One of the interesting things about it is the way it manages memory! Unlike other browsers which have one process for the browser and shared memory between tabs you open, in Chrome, each tab has its own process and its own memory!

This results in better performances, no “bad interactions” between tabs (in other browsers, if a tab crashes, the whole browser crashes) and… well, see it by yourself, they made a little comic that explains why everybody (running windows for now) should install Chrome:

http://www.google.com/googlebooks/chrome/ for the comic

http://www.google.com/chrome to download it

Thanks Phil for telling the team about this interesting browser!

03 Sep, 2008

A simple “Calendar-only” date_select

Posted by: Francois In: Rails

In this post, I will explain how to create a ‘fool-proof’ date_select using ActiveCalendar. The trick is to turn the regular text field used by ActiveCalendar into a simple read-only label.

1. If it’s not done yet, install ActiveCalendar ( http://code.google.com/p/activecalendar/ for latest details)

a. ruby script/plugin install http://activecalendar.googlecode.com/svn/trunk/activecalendar

b. Add the following to your layout:

2. After restarting your rails server, your date_select fields should be changed to calendars. Nothing special here:

 

The familiar Active Calendar version of date_select

The familiar Active Calendar version of date_select

Now, let’s create a little partial-helper called _calendar_date_select ( I put it in the “layouts” view folder as it’s going to be used everywhere in the app. Any suggestion for a better place?):
<div id="<%=date_div_id%>" style="display:inline;" ><%=(date_value).to_date.to_s(:for_html)%></div>
<input name="<%=input_name_and_id%>" value="<%=date_value%>" class="text-input" id="<%=input_name_and_id%>" type="hidden"
onchange="document.getElementById('<%=date_div_id%>').innerHTML=this.value">
<img src="/images/calendar.png" id="<%=input_name_and_id.delete("[", "]“)%>_from_trigger” style=”cursor: pointer;padding-left:2px;” title=”Date selector”>
<script type=”text/javascript”>
Calendar.setup({
button : “<%=input_name_and_id.delete(”[", "]“)%>_from_trigger” ,
inputField : “<%=input_name_and_id%>”,
ifFormat : “%Y/%m/%d”,
singleClick : true
});
</script>

Now you can call it from any view to get a nice Calendar-Only date_select that looks like this:
 <%= render :partial => "layouts/calendar_date_select",
:locals => { :date_div_id => "establishment_date", :date_value => Date.today, :input_name_and_id => "company[establishment_date]” } %>

:date_div_id being the id of the div containing the label (as it must be unique on the page)
:date_value is the default value of the selected date
:input_name_and_id is the… name (and also id) of the field you will receive as a parameter in your controller when submitting the form.

Calendar-Only select_date

Calendar-Only date_select

3. A little “extra” feature: If the default date format displayed in the javascript doesnt suit you, you can use the following extremely convenient javascript: http://blog.stevenlevithan.com/archives/date-time-format

Then, simply change my code from
onchange="document.getElementById('<%=date_div_id%>').innerHTML=this.value"
to, for example:to, for example:
onchange="document.getElementById('<%=date_div_id%>').innerHTML=(new Date(this.value)).format('dd mmm yy')"
That’s it :-)

About

SafeComs Thailand is a privately-held Bangkok-based company established in 2004 by a group of security engineers, based on the expertise they acquired during 5 years in Australia. We are committed to building the best Security Solutions possible with the minimum number of features necessary to make your company safer, your life easier and our products affordable!