I never really needed to look for another language to learn once I was acquinted with ruby some years back. I love it, and I really do. It provides clean code which does what it reads – it feels like the language was written for me, which was infact the idea behind ruby – a language made for developers.

But, anyways, I am giving Python another try for with hopes that it will be fruitful for me to learn the language. It has been, I think, 2-3 years since I last tried the language for some time, briefly. I have learned a lot in that duration in the Ruby world. And, I am hoping, if nothing else, this attempt at Python will make me a better rubyist. This post describes my notes on setting up a development environment for Python on OSX 10.8 (Mountain Lion), and some initial learning intakes.

Read on →

OK, I have been doing a lot (and I mean, a lot) of work on Rails, recently. I have always loved the simple expressive syntax of Ruby, anyway, so that does not bother me.

Now, in one of the projects, I have been using ActiveAdmin, and other awesome gems like FactoryGirl, RSpec, Cucumber, etc. And, every now and then, I come across a concept or feature about these gems that I was not aware about earlier. I wanted to quickly jot down all these things, in a single place (for future reference). Now, many of these things might not be new to you, but are to me and are of importance for me. I am wondering if I should have used a different title for this post, now.

Read on →

Oh, so, you have tried implementing custom filters in your shiny ActiveAdmin interface, and probably, have already started despising the time you have wasted in searching for an answer? Yeah, it happened to me, as well.

Anyways, this post contains my short notes on using ransacker to create powerful search patterns in my ActiveAdmin interfaces. Definitely, ransacker is really powerful. You only need to convert the incoming search filter (e.g. text or ids or anything else) to an equivalent attribute in the database, and you are done :)

Read on →

As stated a few posts back, I have switched to using Pow for managing my hosts configuration.

Recently, I was using omniauth-twitter to authenticate a client for my Rails application. When trying to access the application’s oauth url for twitter, i.e. /auth/twitter via the pow based domain I was getting a 401 unauthorized error, while accessing it via the Webrick’s http://localhost:3000 worked fine.

I was scratching my heads over the reason, when I noticed that I was using Environment variables in my provider definition, and I wondered probably Pow does not have access to these variables? I use dotenv and was pretty sure webrick had access to these Environment variables.

So, I googled for a while and found that Pow actually does not have access to dotenv based variables. Instead, it does allow setting them via a .powenv file. Therefore, I ran the following commands to configure all this from my Rails’ root path:

1
2
3
echo 'export TWITTER_KEY=<MY-TWITTER-KEY>' >> .powenv
echo 'export TWITTER_SECRET=<MY-TWITTER-SECRET>' >> .powenv
touch tmp/restart.txt

And, voila! I can now access my oauth workflow, simply.

OK. I am really happy with my recent endeavour to try out Pow and making it work alongside Apache. What this means is that, on my macbook pro, I can simply run powder link inside a rack-based application, and then, use http://<appname>.dev to connect to this application. For legacy (non-rack) based application, I can simply create a directory in a specificied location, and that directory will be served by Apache at: http://<dirname>.lab. Details for this implementation/workflow can be found in this post.

Now, this works really nicely. But, I wanted a way to access these sites easily on the public internet, lets say, to showcase the current work to a client, etc. This is where ngrok comes in. It allows us to establish a tunnel that forwards a port on our machine and make it available on the public internet. This post walks through the steps I took to make it play nicely and really smoothly with Apache and Pow.

Read on →

I have started using Pow lately, which I have avoided for a long time, without any explicit reasoning. Now that I have actually tried it, I can definitely say that using Pow is really a breeze, and is really powerful at the same time. Before this, I used to run Phusion Passenger for my needs, and while that was a lot more powerful, it was a lot more fuss for my naive needs.

Now, Pow is really great for Rack based applications, but does not work well enough with other applications, e.g. the ones using PHP. What makes it worse is that the default Pow configuration takes over the port 80, and thereby, my Apache server will never be hit. Great.

I, quickly, googled some stuff and found a way to make Apache and Pow play nicely with each other, and at the same time remove the need for dnsmasq, which I am, currently, using to resolve arbitrary top-level domains. This post contains my notes on this topic.

Read on →

While working on a gem, I needed to generate ruby classes on the fly. Yeah, I know this should never be the case, unless I needed around 600+ classes (I was converting schema.org schemas to ruby classes).

Now, this required me to add descriptive text inside these classes, but the text was very long and I hated how the text overflowed the screen. I use vim, which promptly highlights the 80-char column marker on my source files, and I wanted this text to stick to that. Effectively, I wanted something like the following:

1
2
3
4
5
6
module MyModule
  class MyClass
    describes "A really long text that respects the 80-char column marker and
    wraps nicely when it exceeds this length."
  end
end
Read on →

It’s wonderful. This new year. The 2014.
Everything seems different – not in their appearance or behaviour or properties, but it feels like things have a new soul, or like an invisible painting has been performed on them to give them a more living feeling.

I know. I know. New year, sometimes, have such an effect on individuals, and I am no different. I am a person who appreciates art, and the new year just happens to bring so much of it. So, let me first wish a new year to you and to me, with a wish that this year will give us the ever-elusive satisfaction every one wants in their life, that this year will bring us closer to our dreams – the precious!

Read on →

Well, before you do that, I will do it from my side: Happy new year to you!

So, I was just working on somethings, and found this nice little code snippet that was totally appropriate for this event.

Read on →

As stated in my post titled Back with a Bang! (that title, still, amuses me), I have moved from WordPress to using Octopress on Github pages. I was happy with my new blogging configuration, and I think, I am on schedule with my post updates, till date. However, in making the switch, I messed up my email configuration while setting up custom domain for this blog. And, I was not even aware my emails were bouncing off, silently.

Read on →

Copyright © 2014 - Nikhil Gupta - Powered by Octopress