Getting started with Android and CircleCI

Continuous Integration provides many benefits to the software development process. Did I break the build? How many of our tests pass on the latest version? How can we distribute the latest version of our app to our testers smoothly? Continuous Integration can help answer all of these questions.

For those that have been around for a while, there have been many CI tools (CruiseControl) along the road to CircleCI and many are still relevant (Jenkins).

Yesterday, I started looking at CircleCI in depth after watching Donn Felker’s excellent video on Caster.io and here are a few simple steps to get started with CircleCI and Android.

To start, sign up for a CircleCI account here and sync your Github repositories.

Add a project that you would like to add to CircleCI. CircleCI will try to build your project automatically, but to maintain better control over your CI process you should use a circle.yml file. This file should be placed in the base directory of your project.

A sample circle.yml can be found below. Change the words CriminalIntent to the name of your project and make sure that the build-tools version in the circle.yml matches the build tools version in your build.gradle file for your app module.

https://gist.github.com/dazza5000/0a807de012c7281f14787cf30bf7be0e

Check in the circle.yml file and push it to GitHub.

CircleCI should now automatically build your project!

Screen Shot 2016-05-01 at 6.23.56 PMTo see what a passing build looks like you can check here:

https://circleci.com/gh/dazza5000/CriminalIntent

Full source for the project including the circle.yml file and build.gradle can be found here:

https://github.com/dazza5000/CriminalIntent

 

giphy

Where to put the gradle.properties file on Jenkins

TL;DR: Put your gradle.properties file in the /var/lib/jenkins/.gradle/ directory on a standard Ubuntu install.

Sometimes you need to have a gradle.properties file that is not included in your git repository. Many times this is because you need to have an api key that you would not like to be made public.

Because your gradle.properties file will not be checked into your git repository, the job will fail to build if your api key value is not able to be found.

One way to fix this is by placing your gradle.properties file in a place that jenkins will look for it. By default this location is in the .gradle directory of your Jenkins user.home directory.

To find the user.home directory open the Jenkins console in your browser, click “Manage Jenkins”, and then click the “System Information” link.

Scroll down until you find “user.home”

Screenshot_2016-02-08_17-26-12

In this example, the user.home directory is /var/lib/jenkins.

Now that we know this, we need to copy our gradle.properties file that contains our api key to /var/lib/jenkins/.gradle

For example:

sudo cp ~/source/a-caring-text/gradle.properties /var/lib/jenkins/.gradle/

Change the file permissions so that Jenkins can read the file:

sudo chown jenkins:jenkins /var/lib/jenkins/.gradle/gradle.properties

Now you can build the job that was depending on this api key!

raw

Working print_it.c for Sam’s Teach Yourself C Programming in 21 days

It’ s always awesome being blessed with incorrect code snippets in beginner programming books. Luckily, I have enough sexy house music to work through anything (thank you radio 1!). If you’re looking for a working print_it.c example, look no further!

much thanks to: http://www.programmersheaven.com/mb/beginnercpp/367391/367391/newbie-programming-error/ – There are bunch of sites with code for print_it.c and programmersheaven.com was the only one that had working code.

code:

/* print_it.c-- This program prints a listing with line numbers! */
#include <stdlib.h>
#include <stdio.h>
void do_heading(char *filename);
int line = 0, page = 0;
int main( int argv, char *argc[] )
{
char buffer[256];
FILE *fp;
if( argv < 2)
{
fprintf(stderr, "\nProper Usage is: ");
fprintf(stderr, "\n\nprint_it filename.ext\n" );
return(1);
}
if (( fp = fopen( argc[1], "r" )) == NULL )
{
fprintf( stderr, "Error opening file, %s!", argc[1]);
return(1);
}
page = 0;
line = 1;
do_heading( argc[1]);
while( fgets( buffer, 256, fp ) != NULL )
{
if( line % 55 == 0 )
do_heading( argc[1] );
fprintf( stdout, "%4d:\t%s", line++, buffer );
}
fprintf( stdout, "\f" );
fclose(fp);
return 0;
}
void do_heading( char *filename )
{
page++;
if ( page > 1)
fprintf( stdout, "\f" );
fprintf( stdout, "Page: %d, %s\n\n", page, filename );
}
/* print_it.c-- This program prints a listing with line numbers! */#include <stdlib.h>#include <stdio.h>
void do_heading(char *filename);
int line = 0, page = 0;
int main( int argv, char *argc[] ){char buffer[256];FILE *fp;
if( argv < 2){fprintf(stderr, "\nProper Usage is: ");fprintf(stderr, "\n\nprint_it filename.ext\n" );return(1);}
if (( fp = fopen( argc[1], "r" )) == NULL ){fprintf( stderr, "Error opening file, %s!", argc[1]);return(1);}
page = 0;line = 1;do_heading( argc[1]);
while( fgets( buffer, 256, fp ) != NULL ){if( line % 55 == 0 )do_heading( argc[1] );
fprintf( stdout, "%4d:\t%s", line++, buffer );}
fprintf( stdout, "\f" );fclose(fp);return 0;}
void do_heading( char *filename ){page++;
if ( page > 1)fprintf( stdout, "\f" );
fprintf( stdout, "Page: %d, %s\n\n", page, filename );}

now all that’s left is:

gcc print_it.c -o print

./print print_it.c

How to Stream in High Quality with Effects to Justin.tv or ustream.tv on Ubuntu

This is a down and dirty how-to. I found that streaming via WebcamStudio resulted in higher quality streams than streaming directly to justin.tv. This approach also opens up some options not present in the browser based streaming solution justin.tv offers. WebcamStudio is not included in the Ubuntu repositories so we will have to download it manually.

1. Download WebcamStudio from the creators site at www.ws4gl.org. This will eventually forward you to sourceforge. Grab the .deb file from here: http://sourceforge.net/projects/webcamstudio/files/

2. Install the deb file by double clicking it. This will open up the Ubuntu deb installer. The deb installer is now included in the Ubuntu Software on newer releases. Click the install button. (Note: If you have Synaptic open, the installer will hang until Synaptic is closed. This is a bug in Ubuntu)

3. WebcamStudio is installed on the Main Menu under the Sound and Video section. Click the WebcamStudio link to launch the app. You can also press Alt+F2 and type in webcamstudio.

4. Once WebcamStudio launches you will need to select your webcam under devices. Double click your webcam.

5. Everything else should be easy. Click the play button under the Source Layer section. To verify that your webcam is working, click the output menu on the menu bar and select Show Preview. This will open up a preview window.

6. As you can see the coloring is off. To fix this we are going to apply an effect by clicking the effect tab and selecting SwapRedBlue and then enabling the effect by clicking the move button.

7. Now that everything is good we are going to go to justin.tv and login to our account. Click the Go Live! button in the top right and the select webcam. If you only have one video source available on your pc, the video feed from the webcam we previously configured should be displayed.

8. Next, lets do something special with WebcamStudio. Select the Output menu on the WebcamStudio application and then select SinglePaint. This will open up another preview panel that has paint options. We can use this to paint anything on the video stream we would like. If you like these kind of things, make sure to check out the effects tab in WebcamStudio.

Please feel free to donate to www.ws4gl.org.

How to “fix” Bridged Networking in VirtualBox (Ubuntu 11.04 Host / Windows XP Client)

Note: This is not a complete fix, but more of a hack to get internet working on client VM’s when bridged networking does not allow client VM’s to access the internet.

After switching a Windows XP VM to bridged ethernet, the XP VM was no longer able to access the internet. I found a few solutions to this problem and this one seems to be the easiest.

To fix the loss of internet when using a bridged adapter on Virtualbox, configure the VM to have both a NAT and Bridged ethernet adapter. (see the screenshots below). To do this select the VM (must be powered off), click the settings button and then navigate to the network section of the Settings wizard. Configure Adapter 1 to bridged and then enable and configure Adapter 2 to be NAT. Press OK to save the changes and then turn on the VM. Give it a few seconds for the resources to be provisioned. You should now have access to both local and internet resources from the VM.

The NAT interface will be used to connect to internet resources, while the bridged adapter will be used to connect to local resources. This allows you to RDP  or console into the VM from other computers on your local network and still have internet access on the VM.

Adapter 1 (Bridged)

Adapter 2 (NAT)

Some Lightweight Browsers

I have broadband at home, but sometimes during the travels I end up at a library, internet cafe, or public wifi spot that is unbearably slow. When I’m on the internet I want to see what I want to see and I want it now. To deal with this unbearable situation I have been exploring lightweight browser alternatives. In this quest I have found a few that are quite good, extremely fast, and even cross platform!

My favorite so far: Links2

Links2 is a new revision of Links that supports graphics! It is extremely fast, easy to use, and a great way to browse the internet without the clutter. Sites like Facebook will not load, but for reading the news it does really well! If you feel like you don’t need graphics, try just plain Links. It can be used from the terminal and is more than enough to enjoy the web experience.

Close, but no cigar: Dillo

Dillo is another lightweight alternative. Supporting tabbed browsing, Dillo is fast and lightweight, but for some reason lacks the charm of Links. It also seems to crash on my Ubuntu 9.10 install. A major downer.

For those that are feeling adventurous: Opera Mini beta 2 with Microemulator

Opera Mini is by far the best browser I have found in the mobile arena. Why not use it on the computer? If you don’t mind doing a little dirty work, you can get Opera Mini running on your desktop. It is not as fast as Links2 or Dillo, but the browsing experience is closer to what you would experience on Firefox, Chrome, or IE. Opera Mini is an impressive browser, and on a slow connection it makes a great Desktop browser. Opera Mini has a password manager and supports cookies! YUM!

Full fledged browser (not lightweight): Google Chrome

With the addition of Extensions to Google Chrome, I have almost fully transitioned from Firefox to Chrome! If you haven’t tried it out yet, please do. You will most likely be thoroughly impressed with its’ speed and generous real estate dedicated to browsing!

Google Chrome with Extensions (Flashblock, Adblock+, Gmail Checker)

I haven’t been keeping up with Chrome, but I recently did a search for blocking flash and found that both Flashblock and Adblock+ have been implemented in the latest developers release of Chrome 4.0+. Not only that, the boys that get into this stuff have been busy cooking up a whole bunch of other extensions that are quite handy including a Gmail Checker and a Facebook modifier. To get these extensions and others mosey on over to www.chromeextensions.org.

How to Turn Off the Button Lights on the Nokia 5800

The light from the buttons on the Nokia 5800 can be distracting when watching movies. Fortunately, it is easy to turn off these buttons using a program called LightCtrl.

Step 1

Download LightCtrl here.

Step 2

The program is unsigned. You must get it signed to install it. You will need your IMEI to do this.

Find your IMEI by typing *#06# on the touch keypad of the Nokia 5800.

Using your IMEI, visit SymbianSigned.com and get LightCtrl signed.

Step 3

Transfer the signed LightCtrl file to your Nokia 5800.

Step 4

Using the File Manager(Applications->File Manager), browse to the location of the LightCtrl file and install it.

Step 5

Once installed, open the application and set the Primary Keyboard setting to “Light off”. DONE! In addition, I set the Primary Screen setting to “Control by System”.