Skip to main content

Posts

Updating the Raspberry PI GIT server.

I took time to refresh my Raspberry PI GIT server. I am still using the v1 board, but with a few upgrades and modifications. It was more to streamline the entire package instead of performance upgrades. The original Raspberry Pi in a modded case. Changes: I bought a half-height SD to Micro SD adapter. This makes it stick out less from the case. Sadly it’s not totally flush, but better at least. Along with that I upgraded to a 64GB micro SD card from a 32GB SD card. I upgraded the backup drives with 64GB Lexar JumpDrives (S45 LJDS45-64GABNL). They are super compact and had decent reviews. I decided to skip the RAID 01 mirroring approach with these. It simplifies things and there really isn’t any drawback besides maybe hot swap (which I don’t think would work because fstab uses unique drive identifiers). I picked up another power supply on a whim when I saw it at the store “Five Below” for a great price. This again streamlines things over my previous setup that was combo type where you w...

Adjusting Notepad++ to work with an ASP VBScript project.

I have a large project in classic ASP, VBScript, and Javascript. It’s a hassle dealing with it because developer tools don’t support it that well or at all. I recently poked around the open source editor Notepad++ and got it adjusted to work decently well with the project. Check out Notepad++ on the official website here . In the past I had used Eclipse with an old VBScript ASP syntax highlighter. It wasn’t perfect, but worked alright overall. The main issue is that the highlighting stopped working every so often, and not to mention Eclipse is bulky and a pain to use for various reasons. Here is a screenshot of Notepad++ adjusted to work with the project: Here are my main adjustments: “View” >> “Folder as Workspace” “View” >> “Document Map” “View” >> “Function List” “Settings” >> “Preferences…” >> “Editing” >> “Display line number” The function list feature won’t work without modification. My project is broken into a large number of “.asp” files and ...

Using Raphael the JavaScript graphics library.

In this example, I go over a simple use of Raphael.js. It draws 4 boxes on the page and allows you to move and resize each independently. Here is the graphics library (licenses under the MIT license): https://dmitrybaranovskiy.github.io/raphael/ Here is my code on GitHub. The basic gist of it is to initialize the primary Raphael object and apply it to the page. After that you create the boxes you want to draw and associate them with a “drag” function that is called when the user interacts with each box. Here is a selection of the code below: // Define 4 boxes to draw on screen var boxListing = [ { x: '10', y: '10', width: '70', height: '70', boxname: 'Box 1' }, { x: '110', y: '10', width: '70', height: '70', boxname: 'Box 2' }, { x: '210', y: '10', width: '80', height: '80', boxname: 'Box 3' }, { x: '310', y: '10', width: '90', ...

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. Here is the important code for my counter tool: public IEnumerable<string> FilterFiles(string path, params string[] exts) { return exts.Select(x => "*." + x) .SelectMany(x => Directo...

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. 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)); } } The extended timer class takes in the...

C#: Using the Background Worker to thread your application processing.

In this article I go over using the background worker control in C# .NET Framework (Visual Studio 2015). This control allows you to easily do processing intensive tasks without locking up your interface thread. I use this a lot in winforms applications where I expect code to take any amount of time that the user would notice the interface being locked up while processing. This control gives you the ability to send progress updates to the interface thread as well as cancel processing any any time. The code for this example is on my GitHub here. Here is the important code from the main form: public enum CurrentStatus { None, Reset, Loading, Cancelled, Success, Busy } public class MainForm : Form { private BackgroundWorker bwInstance; private Button btnStartWorker; private Button btnStopWorker; private Label lblLoadingStatus; private ProgressBar prgLoadingProgress; private CurrentStatus processingStatus = CurrentStatus.None; public Ma...

Android: Working with Preferences and Settings

In this article I go over using the built-in Android settings and preference system. I have a settings class as well as an activity that manages user input. A spinner is assigned the task of letting the user turn on or off a vibration feature. When the application is started again, the setting is accessed and assigned to the spinner. It also enables or disables the vibrator based on our saved preference. The code is available on GitHub here. Here is our Settings class: public class Settings { public static final String PREFS_NAME = "twoc_settings_example"; public static final String KEY_SETTINGS_AVAILABLE = "settingsavailable"; // your custom settings in the application public static final String KEY_STATE_VIBRATION = "vibrationstate"; // the object used to access settings for this application stored in a predefined setting area SharedPreferences prefAccessor; public Settings(Context parentContext) { prefAccessor = par...

Javascript and HTML: Async Communication Prototype

In this article I go over an asynchronous communication prototype I had made in straight Javascript that you use to POST to a server script and pass along the response to a Javascript function specified by the initial call to the prototype. The main benefit here is that you don’t need a full page refresh, which is great for implementing web interfaces that have an application feel to them. It doesn’t use any bulky libraries and should work on all browsers. An ideal use case for this would be websites hosted in an internal network that you wanted to act like an application. Though, with extensive modification you could add security features or just run it through https with proper verification code in the PHP script. The example code is located on GitHub. In my example I have four files: example.html = the html page that gives the user two buttons that fire off asynchronous calls to a server side script. AsyncManager.js = The prototype (aka. class) that handles communication and respons...

Android: Basic game loop with scaled graphics.

In this article I go over implementing a simple game loop with a custom view. The standard draw method is used with some timing checks so that we can get an approximately consistent refresh rate. This is a somewhat simple way to get started without having to use something OpenGL. The full source code is on GitHub. The main activity handles the creation of our custom view and passes along screen size information once it’s available. This is a key step because it allows us to get that screen information before the view actually starts being displayed. I have a previous tutorial on just that here so I am going to omit the main activity code and the related xml layout file. If you want an exact game update loop structure, you might need further restrict any numeric changes in your game specifically by time rather than having them in the middle of the draw loop that is approximately updated on a given time frame. I haven’t done any testing to verify if that’s needed or not. Also, read up o...