Categories
Articles

How To Check a Web Page For a String Using .NET C# Using HttpWebRequest

using System.Text;
using System.Net;using System.IO;
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);myRequest.Method = "GET";WebResponse myResponse = myRequest.GetResponse();StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);string result = sr.ReadToEnd();sr.Close();myResponse.Close();

//Now, once you have this, perform the search on result string
int stringFound = result.IndexOf("My search string");

Categories
Articles

Update your RSS reader. Now using Feedburner. Thanks!

Link: Update your RSS reader. Now using Feedburner. Thanks!

Categories
Articles Software

Android Project Part II: Reading RSS Feeds

The first real goal for the Android app was getting news updates into the app.  One of the main goals of the app is to be able to get up-to-date information that mirrored that of the harvesttn.com website.  As you probably already know, content is typically served up using an RSS feed in today’s world.   With that in mind, the first real piece that I needed to write for getting news notifications was to build a way to consume and display an RSS feed.

One of the great things is that reading an RSS feed
in code is an extremely common activity.  The first thing I did was look for a library that I could use to grab and read the feed.  I eventually found an article from IBM with code using Android’s SAX parser to parse an XML feed and place it into a ListActivity.

I copied over the code, and basically used the MessageList class as a template for my NewsUpdates class in my app.  Not much needed to be changed, except for the way it loads the feed.  The code on IBM’s site grabs a feed from a hardcoded URL in the FeedParserFactory, and out of the box only contains a .getParser(ParserType type) method, passing in what method you want to use to parse the XML (I used Android-SAX).  I figured that I may need to reuse the FeedParser again, so I overloaded the getParser method to pass in not just the type, but also a feed url, as you can see me using  in the code below.Once I did that, the rest of the code is just getting and displaying the information that the FeedParser got for me.  first, you just get the items out of the parser into something that you can use. Here’s a simple way to get and parse the RSS feed, modified from the ListActivity in IBM’s code and simplified for easier use. Here’s a simple way to get and parse an RSS feed once it is modified (read the whole article if you’re cutting corners):

/*In a ListActivity class, this is in a loadFeed(ParserType type) method. Of course, this isn’t really necessary to read a feed. Only down to the “List<Message> messages = parser.parse();” line is necessary. You can then iterate through each message and call standard getters for each of the items to get the Title, Description, etc.*/

//Get a new FeedParser from the factory.
//Pass in the type of library you want to
//use as well as the URL of the feed
//you want to grab.
FeedParser parser = FeedParserFactory.getParser(type, getString(R.string.News_RSS_Feed));

//Parse the feed into the Messages so you can
//use the feed data more easily in your app.
List<Message>= parser.parse();
String xml = writeXml();

//Iterate through each RSS entry and grab the titles to use as the content in the ListView
List<titles>= new ArrayList<string>(messages.size());
for (Message msg : messages){
titles.add(msg.getTitle());
}

//Add the ListView via an ArrayAdapter
ArrayAdapter<string> adapter =
new ArrayAdapter<string>(this, R.layout.row,titles);

this.setListAdapter(adapter);

DONE! Simple as that. RSS is a great way to integrate content into you mobile application and have a similar (and often better) experience to the web version. The original IBM post is located below, where you can also download the full source.  This code was writted for Android SDK release 3, but it worked perfectly with the 7th release (Android 2.1). Remember that when you copy over the code into your project, ensure your manifest file properly registers all the appropriate activities. Otherwise, you’ll get a force close.: http://www.ibm.com/developerworks/opensource/library/x-android/index.html

Categories
Articles

Android Project Part I: Background

For starters, let me give you some background on starting this blog series.  I spend a lot of time looking things up and learning.  The downside?  I forget things.  So, this will be a win/win.  I can write things I find out down here so that I don’t forget them AND since Google will crawl this site, I will be more likely to re-find it in the future!

I’m going to be writing a miniseries on Android App development.  My home church is Harvest Community Church (or Harvest for short) in Kingsport, TN.  Like many churches, you can get updates, listen to sermon recordings, watch videos, and the like.  The problem for people like me who are very mobile oriented, is that I rarely “go” to a site from a real web browser anymore.  There’s an “app for that” on my phone that aggregates all that information and brings it straight to me.  My calendar, contacts are all synchronized with Facebook and Twitter and my information is all brought to me via Google Reader and the magic of RSS.

The problem is that trying to stay up-to-date with what’s going on at the church from day-to-day is hard!  Nobody wants to have to spend 15 minutes swyping the bulletin calendar into their phone.  This is the motivation behind HarvestDroid and what I want eventually to be an open source ChurchDroid template for any church to use (replacing RSS/Photosharing/Content addresses and locations). My initial requirements and posts will be:

Requirements

  • A Tab menu to divide the following sections
  • News Tab
    • This is a list of announcements
  • Radio Tab
  • Sermon list
  • Videos
    • Open media with music player intent
    • Open media with embedded player
  • Visit! Tab
    • Phone call integration
    • Email integration
    • Google Maps Directions/Navigation Integration
  • Future Enhancements
    • Android notifications of updates
    • Social integration
      • Facebook?
      • Foursquare?
    • UI Skinning (Gotta fancy it up, right?)
    • Offline Access/Caching (This targets 3G/Media, so I assume the app to be connected 99% of the time you use it)
    • Add events to the Google Calendar app

So, as of now, that seems like a nice list.  What do you think?  If you had a mobile app for your church, what would you want to help you stay connected?

Categories
Articles

Software Development: Academic VS Real World Education

Should you learn software development by going to school? Or go straight to the real world? That largely depends on what you want and where you are in life.

I am lucky. I knew that I wanted to do something in computers since I was in the 5th grade. 

My class got an old (new) machine with a green screen, a math/vocabulary game starring a rabbit, and my favorite – BASIC (the programming language). Yes, “10 Print” and all. I wrote my first video game on that machine’s Magic 8 Ball. It was pretty simple. You entered your name and your gender, and then, if you were the girl that I liked in class, it would tell you who you would end up kissing me by the end of the day. Ahh, memories. How did I learn how to code that? I can’t even remember. Was it learning from class? Was it trial and error and figuring it out? What was the most important?

As I got older, I took dual enrollment classes in high school, one of which being a programming class where I met a guy from a state government agency that offered me a paid, full/part-time internship that I ended up taking all through college. I got four years’ worth of experience working as a developer on systems that hundreds of people used, and the apps eventually won awards. At the same time, I also got a CS degree. I graduated with four years of experience under my belt (not lame tedious internship work, actual hardcore enterprise-level .NET development work). Who does that? I then went on to graduate school at George Mason, getting my MS in Software Engineering over the next two and a half years full of long nights of theory and projects. To pay for grad school, I got a job at Amentra, Inc. in 2007. At that time, it was an aggressive, young software consulting company where almost everyone in the company was in their 20s or, at the most, 30s. I worked there by day and took classes two nights a week. The projects were long. I learned enterprise Java and .NET, JBoss, Biztalk, Sharepoint, ESBs, SOA, Agile, and more. Everything was new to me, and every client needed me to be an expert yesterday. Many times, my school suffered because I was working late. Other times, I would walk into a class to rattle off the final exam as soon as I walked through the door. Eventually, that little company got bought by Red Hat, Inc., which is when I thought I had arrived. I couldn’t believe it. In just seven years into my development career, I had gone from a town of a few thousand people where nobody leaves to working for THE Red Hat. I learned and heard many things during that time about how software, people, and the world works.

I’ve heard many people say that “Grad school is nice, but you learn all that stuff at work anyway, so why would you need it when you can just learn it by working?”.

Ok, first off, I worked at Red Hat. I don’t know about you, but working at Red Hat, Microsoft, or Google is not exactly your “typical” software company. Especially where I am from, Northeast Tennessee, not everyone is as bleeding edge as the Juggernauts of software. Here are the PROs of education in software engineering and computer science.

  • The academic environment gives you the resources to study topics and projects that EXCITE YOU.
    • You aren’t getting paid, so you can build whatever you want.
    • Schools have labs and funds to get you the hardware and software you need to build the project of your dreams.
  • You get a big piece of paper.
    • Computer scientists and software engineers know that technology changes. Still, the person hiring sees that you have a big graduate degree tick beside your name, which bumps you above the next candidate.
    • Hiring managers often see graduate school as a replacement for work experience. So, what happens if you work AND go to grad school? Extra free years? I’ll take it.
  • You get PRACTICE. Education without practice and understanding brings you nothing. Software development is a craft. You perfect your work through practice. Eric Raymond, the author of The New Hacker’s Dictionary, says, “Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter.”
  • You learn to work with “contrary” people.
    • Many of the most challenging problems you will encounter as a developer are people problems. 

Here are the CONs of education in software engineering and computer science.

  • It costs money.
    • Grad school costs tens of thousands of dollars. On a positive note, many employers will allow you to expense your tuition in exchange for a certain number of years’ commitment. Generally, more advanced leadership positions in more traditional companies require an advanced degree to match.
  • You could be spending that time making money.
    • With the time you would put into classes, you could have a second job as a freelance developer or work on an open-source project to gain experience.
  • You don’t need a degree to write high-quality code.
    • I’ve seen people from all walks of life transition into software development. I’ve seen former teachers, cognitive science majors, chemists, CPAs, lawyers, English majors, artists, musicians, you name it. Lack of formal education can always with experience and hard work.
    • Formal education can always be substituted by more focused hard work since formal education typically has a very structured goal and plan for achieving that goal, combined with projects that help you practice concepts. These outcomes manifest when you do the work yourself, with the only difference being the grades and degree recognition.
  • You don’t get experience working with a large team.
    • Five people is not a “large team.” Large teams can include dozens of developers, a whole testing department, an operations team, a security team, and more. Classroom projects can be more fun and motivate you, but the social dynamic is just different.

When you look at someone who has advanced school credentials, remember that the value is still about hard work and experience over time. Graduate school is an excellent opportunity to work hard and learn a lot and, indeed, was the right choice for me. Always remember that additional schooling is just that – an opportunity. I had to work hard for the degree to mean anything other than a piece of paper, just like you will.

If you want to read more about hard work in Software Engineering, here is a great, timeless article: Teach Yourself Programming in 10 Years by Peter Norvig.

May I also suggest: Discipline Outdoes IQ in the Long Run.

Categories
Articles

What's My Motivation? OR Resuming Old Projects

Writing software can be both a job and a hobby for many of us, and we all have projects sitting out there that we start and never finish.  Some of them, however, are farther along or more useful than others.  When we remember that we need to finish a project, whether at work or at home, you can use these tips for getting things done immediately to get back to your life!: