Harry Seldon's blog

Psychohistory on Rails

Read

Markdown and typo

Posted by Harry Seldon on November 30, 2008

Thanks to Cyril* I have just solved a weird problem I had with Typo. To write my posts, I use Markdown. When I began to use Typo I did not know how I could use Markdown. First, I simply wrote in the visual rich editor but then Markdown was not taken into account. So I used the ‘source’ mode, there it was working. Except that the carriage returns where not displayed by this view. So, as long as I was typing the post it was ok but when I wanted to go back to a post it was really ugly. Thus I saved my posts in a text file and if I wanted to update one I updated the text file and copied and pasted to typo. You imagine the pain !
I have long thought this stupid problem was due to a bad configuration. Somehow it was. A way to solve this problem is to go to Settings/Write and choose ‘Use simple editor without live preview’ instead of ‘Use visual rich editor’. The catch is with that you won’t be able to have a … ‘live preview’. There is at least one other person wishing a ‘live preview’.
I am glad to have Typo fully working now !

* To be precise Fred also helped me on this subject some time ago but his answer, while correct, was not precise enough and I had not understood it, my bad. Thanks all the same !

Posted in | no comments |

Migration to KDE4, nvidia, show desktop, quicklaunch, and multiline taskbar

Posted by Harry Seldon on November 19, 2008

With the migration to Intrepid, I got KDE4. The first impression is ‘wow it is shiny’ ! The second impression is ‘does it work’ (it was not) ? The third impression, once it works, is ‘how does it work’?

Posted in | 5 comments |

Kubuntu migration from Hardy to Intrepid : a piece of cake (or not)

Posted by Harry Seldon on November 19, 2008

In life there are things that change and things that do not change. Linux is an always changing and evolving thing. However, the fact that after each migration I lose my wifi connection is something that does not change. But now I am used to it, so before the migration I pulled my ethernet wire to be ready and happy! Let us see how this migration from Ubuntu 8.04 (Hardy Heron) to Ubuntu 8.10 (Intrepid Ibex) went.

Posted in | no comments |

Grand Gardening with GIT

Posted by Harry Seldon on November 08, 2008

Why is GIT so interesting ?

With git, I have been doing some gardening these days. Indeed I growed trees, cut branches, grafted branches.
I have been using a Version Control System (VCS) only for one year. That is about since I started the Thinkosphere project. I have been using SVN. At first I was like “Hey this is so cool”. SVN is a real time machine or at least a past time machine. You can easily go back in time to get the state of your source code from months ago. Unfortunately you cannot go forward to the future (with GIT you will be somehow able to do that !).

Posted in | 4 comments |

A test and example app for Open Flash Chart Rails plugin

Posted by Harry Seldon on November 07, 2008

On October 24th, David Lowenfels aka dfl added the beginning of a test app in OFC plugin. As I had myself a local test app used to play around with OFC I thought it would be nice to add my test code in the OFC plugin. This code is actually made mainly by Charlie’s examples taken from his blog and my own examples.

Posted in | no comments |

Typo plugins for "recent comments" and "related posts"

Posted by Harry Seldon on October 26, 2008

I have been using Typo for 3 months and I am enjoying it so far. So after 3 months, I want to dynamize my blog. An easy way is to show the recent comments in the sidebar. Fortunately there is a nice plugin to do that: recent_comments_sidebar. To install it, if you have Rails 2.1 or above, simply run:

script/plugin install git://github.com/fdv/recent_comments_sidebar.git

If you have Rails 2.0.2, get the code from github and copy it to your plugin folder.

Posted in | no comments |

Radar chart example with OFC2

Posted by Harry Seldon on October 23, 2008

Following up from yesterday’s example of a scatter line chart. Here is an example of a radar chart. The purpose is double. the first one is to test OFC2 plugin update (let’s say it now: it works !), the second one is to make an example. As Charlie pointed it out, I am leaving the php code to show that if you need further information on OFC2 rails plugin API you actually only need to go to OFC’s original website. For instance, the code from this example is taken here. Notice there are 2 other examples of radar charts here. Let me know in the comments if you have translated to Ruby one of them.

Posted in | 10 comments |

Scatter line chart example with OFC2

Posted by Harry Seldon on October 22, 2008

Yesterday, I needed a scatter line chart for my project. I saw that my current version of OFC did not do it. However, I saw that a new version that has the feature had come out : OFC version 2 Gamera. Looking at pullmonkey’s blog, there was nothing new so I was afraid the update was not made yet. Another look, this time directly on github and good news Charlie had updated OFC2 plugin. To be precise, last commit says “open flash chart gamera not tested yet, but available for those that want to try it out”. So let’s try out the part that interests me: the scatter line chart. I am directly translating this example from Teethgrinder just like I had done for another OFC example.

Posted in | 4 comments |

LEND to the rich, GIVE to the poor (not the opposite)

Posted by Harry Seldon on October 11, 2008

We are in the eye of a stock market cyclone. How did we get there ? One humoristic explanation of the subprime crisis can be found here. Another way to say it is that the financial world completely inverted the roles by lending a lot of money (I am not speaking about microcredit) to the weaker classes and by speculating on them instead of lending money to strong companies.

When I was a child, I was always surprised when hearing the proverb “people lend to the rich”. As many, I was surprised because the first reaction is to think rich people do not need money, poor people do need it. So the logical thing seems indeed to lend to the poor. However, to lend is not to give. In fact, lending money is not only a time exchange. I transfer you this money now, you will transfer it back to me later. But it is even a sale. I am selling you this money for this price (interest rate). So some of our great financial engineers sold expensive products (home and loans) to people who could hardly afford them. Worst of all they speculated on these products, resulting in destroying the value of both the home and the loan. While they did that they GAVE money to the rich. Lehman Brother’s CEO made 500 million dollars in eight years and he was already rich before being CEO. More generally, the whole finance world created crazy wages.

At the same time, companies in the industry got troubles borrowing money and went on a harder pressure to make profits whatever it takes. One such extreme solution is offshoring. On the paper, it seems to generate profits, but globally it destroys value because it destroys the experience acquired by the workers, engineers and management teams (about everyone is impacted by offshoring). This experience is something totally concrete which has a high value. Unfortunately, this value might not be easy to fit in the math models our finance guys came up with.

So let’s summarize : the poor got a money they could never reimburse, companies did not get a money they could reimburse, the rich were given a real part of a money virtually created by speculation. These last ten years finance seemed to work with this motto in mind : Lend to the poor, give to the rich. Therefore, it looks like this remainder is not superfluous : LEND to the rich, GIVE to the poor (not the opposite). With this crisis, there will sadly be plenty of new poor people and there will be plenty of companies desperately needing credits.

Thus, now is the time to actually apply this advice. And finally, if you hear again the proverb “people lend to the rich”, just think back to the 2008 great crisis to remind you what it precisely means.

Posted in | no comments |

Tutorial Rails/OFC/Ajax : Alter the chart using Javascript

Posted by Harry Seldon on September 28, 2008

In a first example I showed how to load a chart using javascript. Here I will show you how to dynamically alter an OFC chart without recreating it. This example is a raw adaptation of this Teethgrinder’s example. The chart is hard coded in ajax code so it is not loaded by OFC rails plugin, this will be done in a next example. Indeed, the aim of all this is at some point to be able to create a chart and then modify it to hide one signal or to zoom in or to change the legend, or etc.

The controller code is simple. Well OK it is even void (as I said the graph is hard coded in the javascript, it gives you opportunity to see how an OFC graph is serialized in json):

class TestItController < ApplicationController
def index_js_4
end
end

Everything happens in the view (index_js_4.html.erb) through ajax code and OFC code. I assume you have installed OFC rails plugin. You need 2 more things: the json2 library available here and the ajax code from Teethgrinder available here. Put these 2 js files in your public/javascripts folder.

The view:

<html>
    <head>
        <%#= javascript_include_tag :defaults, 'swfobject' %>
        <script type="text/javascript" src="/javascripts/swfobject.js">
        </script>
        <script type="text/javascript" src="/javascripts/json2.js">
        </script>
        <script type="text/javascript" src="/javascripts/tutorial-js.js">
        </script>
        <script type="text/javascript">

            function ofc_ready(){
                alert('ofc_ready');
            }

            function open_flash_chart_data(){
                // alert( 'reading data' );
                return JSON.stringify(data);
            }

            function findSWF(movieName){
                if (navigator.appName.indexOf("Microsoft") != -1) {
                    return window[movieName];
                }
                else {
                    return document[movieName];
                }
            }

            var data = {
                "elements": [{
                    "type": "hbar",
                    "values": [{
                        "left": 0,
                        "right": 5
                    }, {
                        "left": 0,
                        "right": 3
                    }, {
                        "left": 4,
                        "right": 8
                    }, {
                        "left": 4,
                        "right": 8
                    }, {
                        "left": 4,
                        "right": 8
                    }],
                    "colour": "#AF99DF"
                }],
                "title": {
                    "text": "Sat Sep 27 2008"
                },
                "y_axis": {
                    "labels": ["Job 1", "Job 2", "Job 3", "Job 4", "Job 5"]
                },
                "x_axis": {
                    "offset": false,
                    "min": 0,
                    "max": 10
                }
            };
        </script>
        <script type="text/javascript">
            swfobject.embedSWF("/open-flash-chart.swf", "my_chart", "550", "350", "9.0.0");
        </script>
    </head>
    <body>
    Here is the chart:
    </p>
    <div id="my_chart"></div>
    <p>
        <a href="javascript:update(data)">Update</a>, <a href="javascript:save(data)">Save</a>
    </p>
    <br/><br/>
    </body>
</html>

To understand this example have a look at the js file tutorial-js.js. It contains the update and save functions. It is understandable even by someone like me who does not speak javascript fluently. You can see the live example here.

Posted in | no comments |

Older posts: 1 2 3 4

Search