Harry Seldon's blog

Psychohistory on Rails

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

Posted by Harry Seldon Wed, 19 Nov 2008 22:22:00 GMT

With the [migration to Intrepid)(http://harryseldon.thinkosphere.com/2008/11/19/kubuntu-migration-from-hardy-to-intrepid-a-piece-of-cake-or-not), 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 | no comments |

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

Posted by Harry Seldon Wed, 19 Nov 2008 22:16:00 GMT

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 loose 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 Sat, 08 Nov 2008 12:17:00 GMT

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 Fri, 07 Nov 2008 22:38:00 GMT

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 Sun, 26 Oct 2008 19:48:00 GMT

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 Thu, 23 Oct 2008 17:46:00 GMT

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 | 9 comments |

Scatter line chart example with OFC2

Posted by Harry Seldon Wed, 22 Oct 2008 20:51:00 GMT

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 Sat, 11 Oct 2008 21:41:00 GMT

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 Sun, 28 Sep 2008 18:38:00 GMT

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.

no comments |

Some useful commands in Linux administration when making a website.

Posted by Harry Seldon Sat, 27 Sep 2008 21:57:00 GMT

This is a cheatsheet of useful commands in Linux administration when making a website in Rails. I am using these commands over and over again so I thought it might help someone.

Linux 
—–
Detailed list of files 
    ls -l 
List the running processes 
    ps -e  
Create a directory 
    mkdir demo 
Kill the use of a specific port (I use it when Aptana/RadRails crashes and do not close the port) 
    fuser -k 3005/tcp  
Delete a directory and subdirectories, without confirmation, verbose mode. (BE CAUTIOUS !) 
    rm 20080120165422/ -r -f -v  
Add a cron jon 
    crontab cron_job.txt 
List cron jobs  
    crontab -l 
Create cron job 
    crontab -e 
Mount a local virtual directory for an actual remote directory 
    sshfs ‘-oworkaround-rename’ username@ssh.domain.com: /home/username/remote/ 
 
MySQL 
—–
Connect to mysql local server: 
    mysql -u username -p 
Connect to mysql remote server: 
    mysql -u username -h mysql.domain.com -p 

Create databases (Rails style) 
    CREATE DATABASE demo_development; 
    CREATE DATABASE demo_test; 
    CREATE DATABASE demo_production; 

Rails 
—–
Create a rails app 
    rails demo  
Install a plugin 
    script/plugin install git://github.com/pullmonkey/open_flash_chart.git 
Install a plugin, force reinstall 
    script/plugin install git://github.com/pullmonkey/open_flash_chart.git –force 
Launch server on a specified port 
    script/server -p 3005  
Open a console where you can send ruby commands to your app (Extremely useful!) in dev mode
    script/console development
Open a console where you can send ruby commands to your app (Extremely useful!) in prod mode (BE CAUTIOUS !)
    script/console production
Migrate the database 
    rake db:migrate 
Migrate the database to a given version  
    rake db:migrate VERSION-22 
Migrate the production database 
    rake db:migrate RAILS_ENV-production 
Install gem  
    gem install RedCloth 
Install a given version of Rails 
    gem install -v-2.0.2 rails  

Git  

Checkout a repo 
    git clone git://github.com/pullmonkey/open_flash_chart.git   
Get the differences 
    git diff 
Fetch from and merge with another repository or a local branch 
    git pull 
Checkout  
    git checkout 
Configure the user settings 
    git config –global user.name "toto" 
    git config –global user.email "toto@example.com" 

H

Posted in | no comments |

Older posts: 1 2 3