Catching up!

A lot has changed since the last blog post (more than three years). I was happily running a successful business around Videocache till Google decided to push HTTPS really hard and enforced SSL even for video content. That rendered Videocache completely useless as YouTube video caching was the unique selling point. Though people are still using it for other websites (whatever supported and not HTTPS yet), I personally didn’t find it good enough for selling. To add to the trouble, Mozilla and friends announced that there will be free certs for everyone. Now, that took away whatever motivation was left to keep working on Videocache. I decided to open source Videocache and the source is now available on GitHub. If you have better ideas or you are looking forward to make things work by forging certs etc, fork it and give it a shot.

After all that mess with Videocache, I am left with a contract job which is not working out well. So, the learning hat is back and I am trying to catch up with the tech world. I didn’t really want to get into the whole JavaScript framework mess because there is no clear winner and there are too many of them but it looks rather unavoidable or Unflushable (if you remember Jeff from Coupling). I have been trying to make simple apps with Angularjs. There is little documentation and you have to dig really deep at times but still you can make things work if you persist. Once you spend some quality time with it, you may actually start liking Angularjs. So, I did give it some time and implemented angular fronted for Pixomatix-Api (another learning project I am working on) and I think I sort of like it now.

In 2015, if you are web developer, you must know how APIs work and you should be able to consume them. So, to learn to expose APIs and version them properly, I fired a small project Pixomatix. Being a Rails developer, you really get obsessed with it and try to implement everything using Rails. Even when you want an API with 2-3 endpoints, you tend to make the horrible mistake of doing it in Rails. This kept bugging me and a few weeks later, I decided to freshen up my Sinatra memories. But working with Sinatra is not all that easy especially if you are used to all the niceties of Rails. Dug up my attempt of implementing Videocache in Ruby, and extracted few tasks and configurations I had automated long time ago. Ended up working a lot more on it and packages into a template app with almost all the essential stuff. Though I need to document it a little more, the app has got everything needed to expose a versioned API via Sinatra.

On the other hand, I tried to use devise gem to authentication for Pixomatix. It was all good for integration with standard web apps and APIs but it sort of failed me when I tried to make the API versioned. Devise turned out to be black-hole when I tried to dig deeper to make things work. I tried a few other gems which supported token authentication but they were also no good for versioning. Generally, you may not need to version the authentication part of your API, but what if you do! Since, this was just a learning exercise, I was hell bent on implementing this. So, I just reinvented the wheel and coded basic authentication (including token authentication) for the API.

That’s it for this post. I am looking forward to post regularly on the new stuff I learn.

 

Insanely Awesome Web Interface for Your Git Repos

Almost 80-90 people visit How To: Install and Configure GitWeb everyday in search of setting up a web interface for their git repositories. Though gitweb is nice, it’s a bit painful to setup and the web interface is not that appealing. The other day I received this email from Klaus Silveira

Hello Kulbir,
I saw your article about installing Gitweb and i decided to send this shameless self-promotion. Maybe you could try my open-source project, GitList https://github.com/klaussilveira/gitlist

I’m looking for beta testers and supporters. FLOSS. 🙂

So, I thought I’ll just give it a try. Today, I got it working and was blown away by the amazing interface! It’s almost like a super simplified version of GitHub. I was so impressed that I immediately setup a demo website at git.gofedora.com for others to look at and fall in love :-)Another good thing about GitList is that it’s very simple to setup. Below is a step by step process to install and configure GitList to expose your public Git repositories to the internet.

What You Need?

You need the following packages before you can setup GitList.

Installing Required Packages

Most modern operating systems have the above mentioned packages installed by default. Even if you don’t have them already, you can use your OS package manager to install them quickly. To install on Fedora/RedHat/CentOS using yum, use the following command

[root@whitemagnet.com ~]$ yum install php git httpd

For Ubuntu/Debian, use the following command

[root@whitemagnet.com ~]$ apt-get install php git apache2

Assumptions

For setting up GitList, I am assuming the following directory paths and other variables.

  • Path to public Git repositories : /home/saini/code/public/
  • Path to Apache document root : /var/www/html/
  • Path to Git executable : /usr/bin/git (Use “which git” to find out for your OS)
  • Web URL for browsing git repos : mygit.example.com/gitlist/

Installing and Configuring GitList

Follow the following simple steps to install and configure GitList.

Step 1 : Clone GitList repository from GitHub to /var/www/html/gitlist/

[root@whitemagnet.com ~]$ cd /var/www/html/
[root@whitemagnet.com html]$ git clone git://github.com/klaussilveira/gitlist.git gitlist

Step 2 : Create cache directory and make it globally writable

[root@whitemagnet.com ~]$ cd gitlist
[root@whitemagnet.com gitlist]$ mkdir cache
[root@whitemagnet.com gitlist]$ chmod 777 cache

Step 3 : Configure GitList using config.ini

Open the config.ini (in gitlist directory) and set the option properly. Refer the sample shown below.

[git]
client = '/usr/bin/git' ; Your git executable path
repositories = '/home/saini/code/public/' ; Path to your repositories (with ending slash)
 
[app]
baseurl = 'http://mygit.exmaple.com/gitlist' ; Base URL of the application (without ending slash)

Step 4 : Make sure your Apache can read your .htaccess file in gitlist directory

GitList utilizes Apache’s mod_rewrite module to  provide nice URLs. Make sure your Apache is configured to read .htaccess from the gitlist directory. Open your Apache config file (generally located at /etc/httpd/conf/httpd.conf or /etc/apache2/ports.conf) and look for the following

<Directory "/var/www/html">

In this segment, make sure you have AllowOverride All as below.

<Directory "/var/www/html">
# Other lines omitted
AllowOverride All
# Other lines omitted
</Directory>

Step 5 : Reload or restart Apache daemon if needed

[root@whitemagnet.com ~]$ apachctl -k restart (or apache2ctl -k restart for Ubuntu/Debian)

Step 6 : Get some sample repositories in your public repo directory

Get some sample repositories in your public repo directory from GitHub.

[root@whitemagnet.com ~]$ cd /home/saini/code/public/
[root@whitemagnet.com ~]$ git clone git://github.com/kulbirsaini/intelligentmirror.git
[root@whitemagnet.com ~]$ git clone git://github.com/kulbirsaini/Railscasts-Sync.git
[root@whitemagnet.com ~]$ git clone git://github.com/zilkey/active_hash.git

That’s all! Now, go to http://mygit.example.com/gitlist to discover your public git repos via a cool web interface! Leave a comment if you face any issues.

 

Getting Started With Git

I have been using Git for years now and I am still a novice user. Actually, if you are an individual developer or work in a really small team, you don’t really need to go beyond using the basic stuff like cloning a repo, committing code, branching and pushing back to the origin repo. And that’s exactly what happened with me. Working alone most of the times and working in my own repos. I never felt the need to explore advanced usage.

Last week, we didn’t have internet at home for like four days. So, I thought I’ll read a book. I downloaded ProGit : The Free Git Book and started reading. It’s an awesomely written book. I learned a lot of new things about Git. A few more concept about using branches efficiently. If you are a Git beginner or looking forward to getting started with Git and you don’t like reading too much, I’ll suggest that you read at least first three chapters thoroughly. That along with a free GitHub account should be enough to get you going if you are not going to be a heavy Git user soon.

 

Summer Hacking

Summer has already started and we (a small group of current and ex-IIITians in Hyderabad) are planning to have some fun digging into Ruby on Rails and related technologies. If you are also interested in utilizing your summer in a productive and fun way, you can join us and share your knowledge while learning from the rest of the members at the same time.

Assuming that all of us know at least one programming language (C/C++/Python), below is the list of things we are planning to learn.

  1. Ruby
    • If you already know a programming language, it’ll not be difficult for you to pick up Ruby.
    • In case you happen to know Python, you’ll feel at home.
    • Spend a good half an hour on Ruby In Twenty Minutes and you’ll know how simple and beautiful Ruby is.
    • Once you are done with Ruby quick-starter, you can try ruby in your browser and have some fun.
    • Please go through Ruby Style Guide to see how to write beautiful and easy to understand Ruby code.
  2. Rails
    • If you have worked with any MVC framework in past, you’ll pickup rails quite easily.
    • If you have worked with Web2py, then go through this Rails vc Web2py presentation which tries to show similarities among both frameworks.
    • RailsGuides is one of best and complete documentation for getting started with Ruby on Rails. It may look like a lot of content to beginners. If that’s the case with you, you can skip the guides in Digging Deeper section.
    • RailsCasts is  like a sea of quality Ruby on Rails screencasts. Watch a few on topics where you may have doubts.
  3. jQuery
    • We’ll be learning jQuery assuming that all of us are already familiar with JavaScript.
    • We’ll learn only basics initially and explore more as we start using it in a Rails project.
  4. CoffeeScript
    • CoffeeScript is a language that compiles to JavaScript but it’s way more beautiful to look at and easier to read and understand.
    • We’ll not write JavaScript code for our Rails app. Instead, we’ll be writing CoffeeScript!
  5. SCSS
    • SCSS is an extension of CSS3. It’s fun to write stylesheets using SCSS as it brings in additional features like variables, nested rules etc.
    • SCSS will ultimately be compiled to CSS.
    • Again, there is not much to do here. Half an hour to familiarize yourself with the syntax and you are ready to roll.
  6. Twitter Bootstrap
    • Bootstrap is a super simple and crazy awesome CSS and JavaScript toolkit developed by twitter.
    • We’ll be using bootstrap to power our Rails apps which we’ll build at a later stage.
    • Nothing much to learn here. It’s more about getting familiar with commonly used classes.
  7. Git and GitHub
    • We’ll be using Git for tracking code while building our apps.
    • We’ll learn about basic Git functions like cloning a repository, committing code, pushing code to a remote repository, working in different branches etc.
    • Go through Git Basics and we can learn more as we start using it full time.
    • We’ll be using GitHub to host all our code. If you don’t have an account already, get one.

We’ll learn these technologies while working regularly at our work places. Once in a while, we’ll meet and share our experiences and knowledge. The plan is to spend one or two weeks to go through basic stuff in all the topics. After that we can start a dummy rails project and learn more as we go.

If you are not in Hyderabad and still want to join, just start exploring and we can connect online! Happy Hacking!!!

 

My New Book on Squid Proxy Server (A Beginner’s Guide)

I have not blogged since a long time mainly because I was a bit busy authoring a book Squid Proxy Server 3.1: Beginner’s Guide for Packt Publications. The book is an introductory guide to Squid (especially the new features in Squid-3 series) covering both the basic aspects as well as the in dept details for advanced users. The book focuses on learning by doing and provides example scenarios for the concepts discussed throughout the book. Access control configuration, reverse proxying, interception proxying, authentication and other features have been discussed in details with examples.

Checkout the links below: