Skip to main content

Posts

Showing posts from May, 2016

C#: Using WebClient on CSV Formatted Stock Data

In this example I wrote a program to pull historic stock data from the ticker “DIS” over the past 10 days from the current date (it will be less than 10 results because weekends don’t have data). I used the .NET Framework WebClient object to request and return the data as a string that I parse into a generic Dictionary. It pulls the data from Google’s finance website as well as Yahoo’s finance site. Of course, check out their terms of use before doing anything with the code. Here is the code that I wrote on my GitHub. I created a class to handle communication with Google’s and Yahoo’s CSV export links. It handles constructing proper links as well as requesting the data and parsing it into a Dictionary that is structured by date. From that point, you could build an application around the use of that data, but for this example we just translate it back into strings for display in text boxes. public class WebClientForStockFinanceHistory { WebClient webConnector; // See Google...

A simple classic VB code counter made in C#

I made this simple application a while back when I needed to quote a project where I was tasked with converting a sizeable amount of classic Visual Basic code into the .NET Framework. This application I wrote allowed me to start my estimation so that I could tie a dollar amount to the work. There is a lot more I could have done to the project, but when you are doing contracted work on a per project basis, it’s important to be efficient. While I did some browsing through the projects that was equally important, this code counter did make a difference in my estimations thereby allowing for a properly researched quote. Now that I’m basically done with the project, I felt that I was relatively close to my estimation. Here is the code for my VB code counter on my GitHub. https://www.youtube.com/watch?v=V86mzyvdSA8 Here is the important code for my counter tool: public IEnumerable<string> FilterFiles(string path, params string[] exts) { return exts.Select(x => "*." + x...

Android: Using the CountDownTimer class

In this article I go over the Android SDK CountDownTimer class. It’s easy to use and gives you the ability to count for projects like a workout timer. In this case we are extending that class so that we can access the methods we need to make it work. Here is the code on GitHub. https://www.youtube.com/watch?v=M_FFZ5sLOyM Here is our SimpleCountDownTimer: public class SimpleCountdownTimer extends CountDownTimer { public static int oneSecond = 1000; TextView textViewTimeLeftDisplay; public SimpleCountdownTimer(long millisInFuture, long countDownInterval, TextView textViewTimeLeftDisplay) { super(millisInFuture, countDownInterval); this.textViewTimeLeftDisplay = textViewTimeLeftDisplay; } @Override public void onFinish() { textViewTimeLeftDisplay.setText("Finished"); } @Override public void onTick(long millisUntilFinished) { textViewTimeLeftDisplay.setText(String.valueOf(millisUntilFinished / oneSecond)); ...