Sebastien Lachance

Learning new things everyday

Learning Rails : SanitizeHelper

SanitizeHelper 

I need to start somewhere and while it may not be the most informative post ever, I’ll try to cover this feature as much as I can. Everything here is already described in the Rails Api so it should be a great idea to keep it as a reference. I’ll also try to add what I have learned 

There are 4 methods in the sanitize helper.

strip_tags

Remove any html tags from your the input provided. If you truncate, you may see <a. strip_tags before you truncate.

strip_links

Remove any links from your markup and return only the text of the link

Problem Downloading files using GeckoFX and XULRunner

GeckoFX is a component to reduce the complexity of embedding Firefox (XULRunner)onto a Windows Forms application to replace the default WebBrowser control.

But while trying to download a file though it, I have encountered this error :

XML Parsing Error: undefined entity
Location: chrome://mozapps/content/downloads/unknownContentType.xul
Line Number 30, Column 18:    <description>&intro.label;</description

After a lot of googling I have managed to resolve this issue. This is what I have done :

1. Use XULRunner 1.9.0.4 or newer

If you’ve followed some tutorials you may have ended up using 1.9.0.0. Use 1.9.0.4

2. Use the Profile Directory

var profileDirectory = Application.StartupPath + @"\EmbeddedFirefoxProfile";
if (!Directory.Exists(profileDirectory))
{
    Directory.CreateDirectory(profileDirectory);
}
Skybound.Gecko.Xpcom.ProfileDirectory = profileDirectory;

3. Copy the chrome folder from the GeckoFX package into the chrome directory of XULRunner.

This will add 2 files to the existing chrome folder.

4. Add a bunch of preferences to greprefs/all.js

pref("browser.download.useDownloadDir", true);
pref("browser.download.folderList", 0);
pref("browser.download.manager.showAlertOnComplete", true);
pref("browser.download.manager.showAlertInterval", 2000);
pref("browser.download.manager.retention", 2);
pref("browser.download.manager.showWhenStarting", true);
pref("browser.download.manager.useWindow", true);
pref("browser.download.manager.closeWhenDone", true);
pref("browser.download.manager.openDelay", 0);
pref("browser.download.manager.focusWhenStarting", false);
pref("browser.download.manager.flashCount", 2);
//
pref("alerts.slideIncrement", 1);
pref("alerts.slideIncrementTime", 10);
pref("alerts.totalOpenTime", 4000);
pref("alerts.height", 50);

Conclusion

I hope it works for you. Happy GeckoFX programming!

APPSUMO and The Bad Ass Developer Bundle

In case you don’t know APPSUMO, subscribe to their notifications. They offers deals that are pretty hard to beat… Look at this one : 

For $47 you get :

  • 60$ at Heroku
  • 30$ at twilio
  • 6 months of SendGrid’s Silver package (479$)
  • 75$ credit at Recurly
  • 4 months at HopToad
  • 2 month at New Relic (400$)
  • 60$ credit at MongoHQ
  • 20 free hours of testing at SauceLabs
  • 4 months at Infochimps
  • And the best one : 60$ credit at Linode (which I buyed a subscription 2 days ago)

My Clojure tutorial failure

I intended to write a full series of posts to help learn Clojure. While I was really enthusiasm about this, my recent change of plans has left me no choice but to abandon the idea of mastering this language. I didn’t knew at that time that I’ll had to learn Ruby for my new project and I have no more time to learn anything else right now. So, goodbye Clojure!

Evernote 4 is better than ever

I am a big fan of Evernote. I used to put everything from personal notes to ebook in it. But, it became so slow it was a pain to open it just to add a little something.

But they released version 4 with a very BIG performance improvement. I will now be able to resume my Evernote’s normal usage.


Linode is my new VPS

I needed to find an hosting company for our new product, and after a lot of though and hard decisions, we decided to go with Linode

I choose a Linode 512 (with Ubuntu 10.04 LTS) because we are not ready for full-scale deployment yet and did not wanted to pay for something we will not use fully for some time. The beautiful things is that we will be able to upgrade with no problems later on.

Installing everything and got everything running in less than 2 hours. And I was pretty new to deploying a Rails application with mysql on linux.

 

Searching for specific text in PHP files

While working on a Drupal project, I had to search for a specific string contained in one of a lots of PHP code files. My first search led me to no result. I assumed that the little something I searched for might be embedded in a dynamic web page (Drupal allows this). I spent some time searching and found nothing. Today, as I worked on another feature, I came across the exact thing I searched for. Humm what could I have done wrong? 

XP has a known issue when you are searching for text contained in files. Hopefully, there is a solution: http://support.microsoft.com/default.aspx?scid=KB;EN-US;309173