Manually trigger Travis CI builds on Pull Requests

This tutorial deals with pull requests on Github which have Travis CI integration.

The day before this was written, Travis CI experienced some issues as a result of which some builds didn’t complete. I had a pull-request open at the time, and the build for it was stuck at “waiting for build status”.

Usually, at that point you would perform a manual build. But if you don’t have access to the repository or the Travis instance, here’s how you can trigger a manual build.

    1. Open a terminal, go to your project directory and checkout the branch from which you created the pull request.
      $ git checkout <some-cool-new-feature-branch>
    2. Amend the last commit with:
      $ git commit --amend

      When git opens your commit message, save and quit.

    3. Force-push to your feature branch.
      $ git push -f <your-fork> <some-cool-new-feature-branch>
    4. Voila! You should see a new build has been triggered.

This works because when you amend your last commit, the commit-hash changes, which leads your CI to see it as a fresh commit for which it hasn’t run the build yet. Since commit-hashes take into account the timestamp of the commit, you will always get a different hash when you perfom a git commit --amend.

A word of caution, though. This rewrites your git history, so you have to be careful when you are doing this. Ideally, don’t do this on branches that others depend on / are based off of.

Originally seen on this comment.


Internet on the Raspberry Pi 2 with a 3G Dongle

I’m working with a Raspberry Pi 2 for my final-year project in college. We needed internet connectivity on the Pi, and a friend (and team-member) of mine had a Tata Docomo Photon Max WiFi Data Card. So we decided to put these two together.

The data card (3G dongle / WiFi adapter) is actually a Huawei EC315. It can act as a USB modem as well as a WiFi access point. And as it turned out later, it was a near-perfect choice for the Raspberry Pi.

I’ll assume that you’re running the latest Raspbian / NOOBs distro on your Pi, and you have completed the initial setup process.

First off (if you haven’t done it already) update your package lists.

sudo apt-get update

Now plug in the EC315. You should be able to see it listed by lsusb. In the picture, it’s the one that says 12d1:1f01 Huawei Technologies Co., Ltd.

Output of lsusb

But you can’t use it to connect to the internet yet. You can see that running ifconfig won’t turn up the EC315.

The 3G dongle is still not recognized as a modem

This is because most data cards these days come with a small on-board memory that contains the necessary drivers to make them work on Windows machines. When you plug them into a Windows machine, this memory is mounted, the required software is installed, and the data card is then ‘switched’ to a ‘modem’ mode that lets Windows recognize it as a USB modem.

But on Linux systems, you need a program to ‘switch’ your data card to ‘modem’ mode. usb-modeswitch is a program that does just that.

Install usb-modeswitch

Install usb-modeswitch by typing

sudo apt-get install usb-modeswitch

Now unplug the EC315 from the Raspberry Pi, wait a second, and plug it back in.[1]

If you run lsusb now, you can see that the device ID of the data card has changed. This is because usb-modeswitch has now switched your data card to ‘modem’ mode.

usb-modeswitch doing its job

You can also see that the EC315 turns up as an ethernet interface in ifconfig. This is why the EC315 is a near-perfect choice: it works right out of the box with usb-modeswitch, with no additional configuration whatsoever. You can now start surfing right away!

The EC315 is shown as eth1

An interesting (and convenient) thing to note is that even if you shutdown your Pi and start it up again now, the data card will still be recognized as a modem. This will make life easier if you want your Pi to run unattended.

If this doesn’t happen with your data card, then you might need to install a program like wvdial that will let you configure a dial-up connection. For more information about this, take a look at this post of Nico’s, that I started off on.

[1] Though just unplugging the data card and plugging it back in worked for me, you might need to restart your Pi if it doesn’t. Supposedly, sudo udevadm trigger emulates a hotplug; but it didn’t work for me.

Sublime Text on Fedora 22

Here’s how I installed and configured Sublime Text 2 on Fedora 22, 64-bit. This should also work for other fairly recent versions of Fedora.


Getting Sublime Text

For Linux, Sublime Text is available as a tarball which contains a pre-compiled executable. So all you have to do is download, extract and run it. You can download it directly from your web browser, or use the following command to download it from the terminal. Don’t forget to escape the spaces in the file-name with a \ (backslash). Note that if your operating system is 32-bit, you should get the appropriate file.

$ wget\ Text\ 2.0.2\ x64.tar.bz2

Extract it using your favorite archiving program. Or you can use tar.

$ tar -vxjf Sublime\ Text\ 2.0.2\ x64.tar.bz2

You may also want to move it to another location, and/or rename it.

$ mv Sublime\ Text\ 2 ~/my/desired/path/Sublime_Text_2

You can now use Sublime Text to create/edit files.

$ ~/my/desired/path/Sublime_Text_2/sublime_text

If you don’t want to type the entire path every time (and I doubt that you do 😛 ), you can either add ~/my/desired/path/Sublime_Text_2/ to the PATH, or symlink the executable to /usr/bin/ (I don’t know if this is a good idea) by typing

$ ln -s ~/my/desired/path/Sublime_Text_2/sublime_text /usr/bin/sublime

Now you can run Sublime Text by opening a terminal and typing

$ sublime my-file-name.txt


Adding it to the Applications list

If you run Sublime Text now, you will probably notice that it has no application icon, and that it’s not present in the Applications list.

To solve this, you have to add a desktop entry for Sublime Text in /usr/share/applications/. To do this, open Sublime Text (or any other text editor) and type (yes, copy-paste) the following:

[Desktop Entry]
Name=Sublime Text
GenericName=Text Editor
X-GNOME-FullName=Sublime Text 2
Comment=Open, view and edit a wide variety of text files

The options are pretty self-explanatory. A couple of important points here, though:

  • The Exec key should contain the command executed when you click on the application icon. If you added the Sublime Text folder to the PATH, this will be sublime_text. If you symlinked it, for example to /usr/bin/sublime, then use sublime.
  • The Icon directory inside the Sublime Text directory contains icons of various sizes. Choose one that looks neat on your screen. The Icon key contains the path to the image you want to use as the icon.

Save this file as sublime.desktop in /usr/share/applications/. Now you will be able to find it in the Applications list. The icon is also displayed.


Making life easier

Now that we are set, we are going to make a couple of adjustments to make life easier. On the menu bar, click on Preferences > Settings — Default. This opens a file named Preferences.sublime-settings which contains various options that can be configured by the user.

First off, tell Sublime Text to convert tabs to spaces. Search for (Ctrl + F) translate_tabs_to_spaces and set it to true.

// Set to true to insert spaces when tab is pressed
 "translate_tabs_to_spaces": true,

If you don’t want auto-complete to enter the suggestion when you hit Enter, then search for auto_complete_commit_on_tab and set it to true. Now you can press Tab to enter auto-complete suggestions, and Enter to enter a newline.

// By default, auto complete will commit the current completion on enter.
// This setting can be used to make it complete on tab instead.
// Completing on tab is generally a superior option, as it removes
// ambiguity between committing the completion and inserting a newline.
"auto_complete_commit_on_tab": true,


If you found this useful, or spotted an error, please let me know in the comments 🙂 In a future post, we will see how to set certain file-types (like .php or .py) to open with Sublime Text by default.

Burning the Arduino bootloader on an AVR

I recently managed to build a crude water-level controller for my overhead water tank at home (expect a post on how to build yours 🙂 ). Being a newbie, my platform of choice was of course, Arduino. When it came to installing the setup, though, I wanted just a micro-controller, and not a huge board with a USB port. Taking the easy way out, I decided to burn the Arduino bootloader on an ATMega8, and upload the code to it.

There is enough documentation on the internet to walk you through every step of the process. So, I will just summarize what worked for me, and provide links to the resources that helped.

To burn the bootloader, you need a programmer. The most sensible option seemed to be Usbasp. I didn’t have one, so I used the Arduino as a programmer.

What I needed / used:

  • An Arduino. I used a derivative called Roboduino, because that was all I could lay my hands on.
  • An ATMega8.
  • A crystal of appropriate frequency.[1]
  • Two 22 pF capacitors.
  • A 10 uF capacitor.
  • A 10kΩ resistor.
  • A breadboard.
  • A few lengths of wire.
  • A power supply. I cut off the connector at the end of a mobile phone travel adapter, and used it as a DC voltage source.

After uploading the ArduinoISP sketch, I connected a 10uF capacitor between RESET and GROUND (also denoted as GND) on the Arduino, because my board was more or less similar to the Arduino Uno.

How I wired it up:

I wired it up exactly as mentioned in the ArduinoISP tutorial. Here is the image for a quick reference.

Wiring up the AVR to the Arduino
Wiring up the AVR to the Arduino.

The bootloader:

All that is left now is to actually burn the bootloader. To do this,

  • Go to Tools > Programmer from the menu and select Arduino as ISP’.
  • Go to Tools from the menu again, and click ‘Burn Bootloader’.

The program:

Now load the program that you want to upload to the ATMega8, in the Arduino IDE. Go to File menu and click ‘Upload using Programmer’.

Going solo:

Now it is time for the ATMega8 to man up and deal with the task at hand :). Just remember that the pins on the Arduino do not translate to the corresponding pins on the ATMega8. You will have to search for “Arduino to <insert micro-controller name here> pin mapping” on Google to find out what the pins on the Arduino actually translate to. Here is what it looks like, for the ATMega8.

Arduino to ATMega8 pin mapping
Arduino to ATMega8 pin mapping

Provide an appropriate power supply, and wire up your circuit as per the pin mapping. I used the same stripped travel adapter for power. I connected pins 7 (VCC), 21 (AREF) and 20 (AVCC) to +5V and pins 8 and 22 to GND (Ground).

The troubles I ran into:

  • avrdude: stk500_getsync(): not in sync: resp=0x00. Ah, the dreaded not in sync! This can be due to a variety of reasons. Mine turned out to be the crystal. I used a 16MHz crystal with the ATMega, while the crystal on board the Roboduino was a 12MHz one. I replaced the 16MHz with a 12MHZ crystal, and that solved the problem. 🙂

Comments and corrections are welcome 🙂

Images are from the Arduino website, and are subject to copyright.

Chrome Bookmarks Bar

For those of you who haven’t discovered it yet, you can create bookmarks in Google Chrome without giving them a name. So, you can simply line up your bookmarks as little icons in your Bookmarks Bar. 🙂

Here’s how you do it.

Create a bookmark by pressing the star on the right corner of the addressbar. Delete all the text in the  Name  field, and click  OK.

Create a Bookmark
Create a Bookmark

Remember to select the Folder as Bookmarks Bar.

You can even create folders with empty names inside the Bookmarks Bar folder, so that a folder icon appears on it, grouping related bookmarks. I did something similar.

First off, I created a folder in the Bookmarks Bar folder, with an empty name. Next, I created several folders for grouping my bookmarks. I named these, and put them inside the folder-with-no-name ( 😛 ).

You can create folders too!
You can create folders too!

This way, I had a folder icon on my bookmarks bar, by clicking which, I could access all my other folders. That made my bookmarks bar pretty neat, and gave me enough room for all the sites I frequented 🙂