November 25, 2011, 19:01
I have always run my Linux on a hand me down box. My current computer, the one I’m using daily always runs some flavor of Windows. When I buy a new computer as the old one isn’t fast enough I will take the current one and make it my new Linux box. As such the Linux box is always one generation or more behind. That means old hardware that doesn’t even have good graphics.
It is that time again, I need a new computer soon. As I was thinking about it I was thinking how well my Linux desktop will run on the new hand me down window box after all it’s still pretty powerful. Then I thought, I have been saying to myself for years that I should start running Linux as my daily computer. I never felt it’s quite “there”, but with my latest Linux desktop experience on Mint 10 I really think it’s “there”.
I do also know why I think its really there, there were two problems that bothered me in the past. The graphics and the resolution on the desktop were just not good enough. I could never get it right on Ubuntu, after I switched to Mint it was practically setup for me automatically. Something I had been digging for both from control panel config settings and lower lever configuration on Ubuntu, it just didn’t happen. The second thing is that I’m used to the windows keyboard and the numeric keypad works differently on Linux. Yes they have windows compatible mode as well that you can set and your good to go. Once I had both these things going I have been pretty happy on the Mint desktop, pretty productive as well.
I think the time is really here, I’m getting a new daily computer that’s going to run Linux Mint. I will keep the current / old box around for windows for a while, just in case. However I will be running the windows stuff I might still need in a virtual machine on the Linux box. That should take care of any windows needs I might have. I can’t see many off hand, maybe some graphics and video editing. Open office will take care of the usual documents or google docs might do just fine. Although Mono develop is available I will most likely have to run Visual Studio, Mono is always a little bit behind .Net. The good news is that Eclipse works fine on any platform. Frankly there is not much that I have to run on Windows anymore and Linux is getting to be pretty nice and usable desktop. Linux has of course always been really strong as a server and that won’t change.
October 27, 2011, 17:32
In order to release your app in the Android market place you need to digitally sign it. The instructions are here. But in short I will show you what you need from the command line, you won’t have to read all the instructions. First off make your app .apk name something different then what your going to use in the end. As the process requires the input and output to have different file names.
Lets take a look, this example is from DOS command line
Create the signature key
C:\Temp> keytool -genkey -v -keystore c:\temp\release-key.keystore -alias MyAlias -keyalg RSA -keysize 2048 -validity 10000
Sign using the key
C:\Temp> jarsigner -verbose -keystore release-key.keystore release.MyApp.apk MyAlias
Verify that it took
C:\Temp> jarsigner -verify -verbose release.MyApp.apk
Run the align tool as recommended
C:\Temp> zipalign -v 4 release.MyApp.apk MyApp.apk
And your all done, now publish it and start watching the downloads.
October 6, 2011, 15:12
I had to setup Postgres on my linux box, configure and make sure it was working. Since that was the case I started the install, then wrote a very simple Java program to connect and retrieve some data from one of the database tables. The install is simple and pretty easy to google. Once your Postrgres database is up and running you should be able to connect to it. You will need a java Postgres database driver, the one I downloaded was the postgresql-9.1-901.jdbc4.jar then add the jar to your project. And finally to make sure your database is accessible from a program you can use the sample below.
//
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
// Simple test class to prove connection to Postgres database
public class Main
{
public Main()
{ super(); }
public static void main(String[] args)
{
System.out.println(” Postgres Test”);
Connection myConn = null;
try
{
// The driver
Class.forName(“org.postgresql.Driver”);
System.out.println(“PostgreSQL JDBC Driver Registered!”);
myConn = DriverManager.getConnection( “jdbc:postgresql://127.0.0.1:5432/testDb”,
“testUser”, “myPassword” );
// Connected ?
if (myConn != null)
System.out.println(“Successfully connected to Postgres Database”);
// Get data from the database
Statement stGetCount = myConn.createStatement();
ResultSet rs = stGetCount.executeQuery(“SELECT * from cars”);
while( rs.next() )
{
System.out.println(“result=” + rs.getString(1) + “,” + rs.getString(2) + “,” + rs.getString(3) );
}
}
catch( Exception ex )
{
ex.printStackTrace();
}
finally
{
try{myConn.close();}catch(Exception IDontCare ){}
}
}
} // EOC
August 29, 2011, 10:13
I found out that I had not played with Text to speech in .net yet. So naturally I went to take a look how easy or hard it is to use TTS in C#. It turns out the hardest part is to find the download link for the TTS install. Its hard to understand how Microsoft sometimes seems to hide download links. Once you find the SAPI SDK page, you would think they would have download links, but not so. However you do not need the whole SDK just to do Text to speech. You only need the TTS download which has a much smaller footprint. But again, where is the download link… ? I found one Microsoft page that doesn’t make it clear, and another third party page that I used to download the TTS install.
And now for the code it self, it’s very straight forward. After installing TTS add reference to your project, choose the COM “Microsoft Speech Object Library” that will create interop dll for your project. Add a reference to the speech library in code and the Hello world sample is only two lines of code.
using System;
//
using SpeechLib;
namespace tester
{
class Program
{
static void Main(string[] args)
{
SpVoice myVoice = new SpVoice();
myVoice.Speak(“Hello world”);
}
}
}
Another choice is to do the same without using the COM object, as COM is heavy. In that case add reference to System.Speech .net library and the code will look like this.
using System;
//
using System.
Speech.
Synthesis;
namespace tester
{
class Program
{
static void Main(string[] args)
{
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.Speak(“Hello World”);
}
}
}
June 4, 2011, 13:32
I had to fix an old plugin I made some time back, I did actually post about it here Java Authenticated POST. So why bring it up again, a good question I say. As Twitter changed their authentication sometime late last year ( Nov 2010 ? ). All programs using the old authentication stopped working. I hadn’t had / given myself time to look at the broken plugin. What the TeamCity twitter plugin does it to tweet when the TeamCity server starts and ends builds. If you follow that account you get notified on Twitter without having to open up your email box to see how your builds are doing.
I went googling about the new authentication and found a nice snippet on StackOverflow The snippet uses Twitter4J library to make the task really simple, check them out. The best part is that Twitter4J only needs Java 1.4 to run. That’s great as my TeamCity server only has Java 1.5 and not the newer 1.6, further as an added bonus their core jar is only 280k, that’s all I needed. Below is my code modified from the StackOverflow sample. It works fine if you are only posting to one account. The tokens and keys can be found on your Twitter app page. If you need to post for different users from your application then your code needs to take that into account. If you want the source of the plugin or all 3 plugins I have created, you can run over to GitHub and pick it up. I made it public domain, open source, whatever you want to call it.
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.conf.*;;
// Updates the twitter account
public static void sendTweet( String psText )
{
try
{
// Configuration
ConfigurationBuilder confbuilder = new ConfigurationBuilder();
confbuilder.setOAuthAccessToken(CxGlobal.ACCESS_TOKEN_KEY)
.setOAuthAccessTokenSecret(CxGlobal.ACCESS_TOKEN_SECRET)
.setOAuthConsumerKey(CxGlobal.CONSUMER_KEY)
.setOAuthConsumerSecret(CxGlobal.CONSUMER_SECRET);
// get the interaction object
Twitter twitter = new TwitterFactory(confbuilder.build()).getInstance();
// send
twitter4j.Status status = twitter.updateStatus( psText );
//
//System.out.println("*** Response=" + status.getText() );
}
catch( Exception ex )
{
System.out.println( “***ERROR=” + stack2string( ex ));
LOG.info( “***ERROR=” + stack2string( ex ) );
}
}
Edit, the 3 plugins have now been added to the official TeamCity PlugIn page
March 31, 2011, 09:12
Playing around with a layout for Android screen finally got me in trouble. The visual presentation in the IDE isn’t exactly the same as when you run in the Android emulator. I went looking around for an alternative, it turns out that a Hierarchy Viewer ships with the SDK. Just load your app and the screen you want to examine in the emulator. Then fire up the Hierarchy Viewer and view your layout from there. This nice little app makes it easy to debug your screen layout. If your on windows goto your SDK lib dir on the command line, something like …\android-sdk-windows\tools\lib\ and execute hierarchyviewer.jar
