Articles tagged 'instructions'

  • Git: Removing sensitive data and rewriting history

    April 27, 2012


    This post was originally published in the Rambling Labs Blog on April 27, 2012.


    One thing that tends to happen with Git, is being careless with what you add to your repository. I’ve seen this happen since I began using Git, a couple years ago, and it stays happening over and over again, for various reasons.

    On one of the projects I was a long time ago, we added lots of files with sensitive information, including emails and passwords for some accounts for certain services. We also added a lot of images that weren’t really needed, and some of the ones that were needed, were not in the optimal size either. We were just starting up with Git, and we didn’t know what to include or exclude.

    To avoid making the story any longer, I just have…

    Continue Reading →

  • Rails - Custom 404 and 500 pages and the exception_notification gem

    April 27, 2012


    This post was originally published in the Rambling Labs Blog on April 27, 2012.


    As I explained before on the Rails 3.1 - Adding custom 404 and 500 error pages post, sometimes you might want to have a custom way to handle your not found and internal server errors. In that case we wanted to show the error with a custom template.

    But, what if I have an important site from which I want to be notified if there is any error raised? There are a couple of gems for this. The one I’m most familiar with is exception_notification gem, which is easily configured as it is depicted on its README.

    This gem is added to the rails middleware stack and will capture any raised error and send you an email notifying about it.

    However, someone pointed out…

    Continue Reading →

  • Writing your blog posts in Markdown with Postmarkdown

    February 3, 2012


    This post was originally published in the Rambling Labs Blog on February 3, 2012.


    Another thing we added to our new site, uploaded back at the end of December, was the ability to write our blog posts in Markdown, which is a text-to-html tool that allows you to write formatted text without actually having to write all the corresponding HTML. Markdown is used for the project wiki pages on GitHub, and can also be used for the project’s readme file.

    Most of the time, I don’t like that HTML gets autogenerated for me, since I usually don’t get the results I want. We used to have the site (which was really the blog only) in WordPress, and I never used the autogenerated HTML. In fact, it was quite the opposite: I wrote every blog post in plain…

    Continue Reading →

  • Migrating your blog posts to Markdown with Upmark and Nokogiri

    February 3, 2012


    This post was originally published in the Rambling Labs Blog on February 3, 2012.


    As I said in my last post, for our new site, we changed our blog engine from WordPress to the Postmarkdown gem. At the end of that post, I mentioned that we had to migrate the old posts from WordPress to Markdown.

    To do this, we built a ruby script using the Upmark gem and the Nokogiri gem. Nokogiri is used for HTML and XML parsing, among other things, while Upmark is used to generate Markdown from a given HTML.

    First, we exported our old blog posts from WordPress to an XML file that looks like this:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
    <!-- ... -->
    <rss

    Continue Reading →

  • Rails 3.1: Treating your '.swf' files as assets

    January 12, 2012


    This post was originally published in the Rambling Labs Blog on January 12, 2012.


    This week, I’ve been deploying one of my current Ruby on Rails projects to WebFaction. For what we found, it’s definitely one of the best options out there for shared hosting with Python and Ruby.

    The application being deployed happened to contain some static flash content (not my idea of course :P), which so far we had put in the public/ directory and had served with no problems so far, while testing locally and on Heroku. However, when we were testing it out on WebFaction, it kept returning 404 errors.

    So, googling for a while, I stumbled into the swf_fu gem. It’s main function is to treat the swf objects as just another asset in the application. So,…

    Continue Reading →

  • Rails 3.1 - Adding custom 404 and 500 error pages

    January 5, 2012


    This post was originally published in the Rambling Labs Blog on January 5, 2012.


    As I said when announcing the Rambling Labs new site, we’ve been learning a lot of stuff while building it.

    Something that we didn’t have the chance to implement on our current projects (but that we will be including soon), is adding custom error pages to the site. So far, what we were looking for was two things: a custom 404 error page and a custom generic 500 error page.

    For the experience I have now with Rails, I thought this would be a piece of cake. Well, in fact… it would’ve been if we were using Rails 2. But guess what? The error handling behavior in Rails 3 is not what you would expect. Even worse, it’s broken for routing errors!

    For what I could…

    Continue Reading →

  • Replacing ERb with HAML on your Rails application generators

    January 5, 2012


    This post was originally published in the Rambling Labs Blog on January 5, 2012.


    As you may know, we’ve been using HAML lately for our views.

    Since I don’t plan to use ERb for my views anytime soon, I want HAML to fit in as smoothly as possible. Luckily, there is a way to replace ERb as the default generated view.

    Just add this line to your Gemfile:

    gem 'haml-rails'
    

    And you should be good to go!

    Now, when you run rails generate controller test method_one method_two, you should see something like this:

          # ...
          invoke haml
          create app/views/test
          create app/views/test/method_one.html.haml
          create app/views/test/method_two.html.haml
          # ...
    

    Way easier than what I thought it would be. But you know, that’s…

    Continue Reading →

  • Using RVM within a cron job

    December 16, 2011


    This post was originally published in the Rambling Labs Blog on December 16, 2011.


    Long time no post! I’ve been really busy these days with some projects. Yet, here I am again, so here it goes.

    A couple of days ago, I started working on a big story in one of those projects I’m currently working on. It’s one of those things that needs to be run a couple of times a day… yeah, a scheduled background job.

    Basically, what it need to do is check some database records, check their expiration date against the current date, and take some actions for each one of the expired ones. Simple enough, right?

    I went ahead and wrote a rake task that would do the heavy work. Something like this:

    task :check_expired_records do
      Record.where('expired =…

    Continue Reading →

  • CoffeeScript: The '=>' operator

    December 16, 2011


    This post was originally published in the Rambling Labs Blog on December 16, 2011.


    As you may know, I’ve been playing around with CoffeeScript for a couple of months now.

    One of CoffeeScript’s jewels that I haven’t talked about yet and that I’ve been using lately on the jQuery Rambling Slider codebase, is the => operator. It is basically a custom function definition, which binds that function to the current context. That is, it ties the this value of the outer scope to the this value of the function being defined.

    How many times, writing JavaScript, have you done something like this:

    var outerFunctionWithCallback = function(options, callback) {
      /* Do something with options */
      callback();
    };
    
    var theFunction = function(){
      var self

    Continue Reading →

  • Extending the jQuery Rambling Slider

    November 30, 2011


    This post was originally published in the Rambling Labs Blog on November 30, 2011.


    One of the core features added in version 0.2.0 of the jQuery Rambling Slider is the ability to customize the transitions between images, between flash elements and between an image and a flash element.

    As it is described in the Adding and Overriding Transitions page in the project’s wiki, in order to do this you have to something like this:

    $(window).load(function(){
      $('#slider').ramblingSlider({
        imageTransitions: {
          /* Add a 'fadeInSlices' transition */
          fadeInSlices: function() {
            /* ... */
          },
          /* Override the 'sliceUpRight' transition */
          sliceUpRight: function() {
            /* ... */
          }
          /* ... */

    Continue Reading →