Friday, January 26, 2018

Manually install .Net Framework without installing Visual Studio

.Net Framework Installation

  • Go to: Microsoft Download
  • Click “Download .NET Framework 4.7.1”, you will get something like this in the Downloads folder: NDP471-KB4033344-Web.exe
  • Right click "Run as Administrator".


  • .Net Framework 4.7.1 Setup, Click “I have read and accept the license terms” and click Install.


  • Restart
    • Start Menu > Run > regedit.exe
    • Find the subkey: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
    • Click V4 > Full > look for “Release”. If it is 461310 (it means .net Framework 4.7.1 is installed)

Wednesday, October 25, 2017

Setting up private NuGet.Server

Date: 10/25/2017

Recently get back into .net world again, was doing some stuff and wish to have something like Maven Repository that manages the libraries. So NuGet is the .net version of Maven. I prefer to host it locally.

References:
Microsoft - Hosting your own NuGet feeds
Microsoft - Setup Nuget-server

There are quite a lot of information out there, but I want to write one myself just a reminder of what I did to make it work:

My Machine:

  • Visual Studio 2017
  • Windows 10
  • IIS (Internet Information Service (Version 10)
  • NuGet.Server - Version 2.14.1
Create APS.NET Web Application with NuGet.Server
  • In Visual Studio 2017 > New > Project > Select "ASP.NET Web Application (.NET Framework". 
  • Right click on the Project's References > Select "Manage NuGet Packages...". 
  • Find "NuGet.Server" and install the latest version. It will change your empty webapp into NuGet.Server app.
  • Accept the override of web.config files and accept any changes it prompted. 
  • At this time, your Project Structure looks like this

  • Update the "Web.config".
    • apiKey: it is used for nuget push command.
      • Example: "<add key="apiKey" value="Test123ApiKey"/>"
    • packagesPath: leave black if you want to use the default "Packages" folder in the project.
      • Example: "<add key="packagesPath" value="C:\Vincent\NugetPrivateInstancePackages"/>"
    • added "identity" on system.web block - this user should have the administrator account that will not have problem creating cache / temp folder. Issue seen when you load "http://localhost/nuget/Packages" url from the homescreen.
      • Example: <system.web><other stuff.....><identity impersonate = "true" userName = "MyAdminAcc" password = "password_for_user">/identity></system.web>
Deploy on IIS
  • I create my own website from IIS Manager.
    • Give a Site Name.
    • Give a Physical Path.
    • Give a Bindings port other than 80.

  • Copy the files over to the directory. Here's example of the files needed.
  • Setup "Application App" for your website.
    • Right click on newly created WebSite from the IIS Manager > Select "Add Application".
    • Configure:
      • Give an Alias.
      • Select the Physical Path.
      • Pick ".Net 4.5" as your Application pool.

  • At this point you will be able to load the webapp by going to the browser: http://localhost:8081/MyNuget, you will see something like this.


Create Nuget Packages

Once you have your NuGet.Server private instance ready, it is time for you to put your NuGet packages up there. Here's how you create your NuGet Package.
  • Visual Studio 2017 >  New >  Project > Select "Class Library (.NET Framework)".

  • Add a "HelloWorld" Class.
 public class HelloWorld
    {
        String _name;

        public HelloWorld()
        {
        }

        public HelloWorld(string name)
        {
            Name = name;
        }

        public string Name { get => _name; set => _name = value; }

        public string GetGreeting()
        {
            return String.Format("Hello {0}", Name);
        }
    }

  • Click Build successfully.
  • Install Nuget.CommandLine to allow running NuGet Command line from Visual Studio 2017.
    • From Visual Studio 2017 > Tools > NuGet Package Manager > Select "Package Manager Console".
    • Execute Command: Install-Package NuGet.CommandLine

  • Run Command to create "NuGet Spec" from where the project file ".csproj" is located.
    • Still in the "Package Manager Console". Make sure you are in the right directory.
    • Execute Command: nuget spec
    • You will see that a new file "MyLibrary.nuspec" is created in the same directory.
  • Edit the "MyLibarary.nuspec".
    • Before:
<?xml version="1.0"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
    <projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
    <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2017</copyright>
    <tags>Tag1 Tag2</tags>
  </metadata>
</package>

    • After:
<?xml version="1.0"?>
<package >
  <metadata>
    <id>Vincent.MyLibrary.GreatUtilities</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>Vincent</authors>
    <owners>Vincent</owners>
    <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
    <projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
    <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>For Internal Testing Only.</description>
    <releaseNotes>This is the First Release</releaseNotes>
    <copyright>Copyright 2017</copyright>
    <tags>Utility MyLibrary Vincent</tags>
  </metadata>
</package>
  • Package your NuGet Library.
    • Still in the "Package Manager Console". Make sure you already build the project.
    • Execute Command: nuget pack
    • For Configuration Specific: nuget pack -Prop Configuration=Release
    • It will create a "nupkg" file in the same directory. It looks like this with both "nuspec" and "nupkg".

  • This is all you need to have "nupkg".
Push NuGet Package to your NuGet.Server private instance.

There are 2 ways to add NuGet Packages file to "NuGet.Server". 
  1. Manually copy the "NuGet Package" to the "Packages" directory.
  2. Push the "NuGet Package" using the "nuget.exe" push command.
Method 1: Manually copy the "NuGet Package" to the "Packages" directory.
  • Copy "Vincent.MyLibrary.GreatUtilities.1.0.0.nupkg" to Website "Packages".
  • From the URL, Click "here" and it will extract and generate the packages ready for consumed.

  • Your "Packages" folder will look like this.


Method 2: Push the "NuGet Package" using the "nuget.exe" push command.
  • From Visual Studio 2017, "Package Manager Console". Make sure you are in the right directory.
  • Execute command: nuget push .\Vincent.MyLibrary.GreatUtilities.1.0.0.nupkg VincentTest123 -Source http://localhost:8081/MyNuget/api/v2/package
  • It will create the same folder structure in "Packages" folder on the NuGet.Server 
How to Consume the Hosted NuGet Library?

The Default NuGet Package Manager is set to "nuget.org" on "https://api.nuget.org/v3/index.json". The idea is to add another package sources to use the Private NuGet.Server that we have setup.
  • In you New Project. Bring up "NuGet Package Manager". Click the "Setting" icon for "Package source".
  • Click the "Add" button to create another Package Source.
    • Give Name.
    • Give Source to your private URL.
  • Once that is done, select the "Package Source" that you have setup. and it will automatically show your Library.

  • The rest is just matter of adding and using it.

Hope it is useful for you.




Wednesday, November 16, 2016

Android App - "BMI Master"

10/14/2016

I have been longing to write an app and put it up on App Store. I recently pick up my slack and start working on an Android App. I called it "BMI Master", is a simple app that calculate Body Mass Index (BMI). I can only work on this over the weekend or after work. After approximately 3 weeks, I managed to put everything together and ready to publish.

The best feeling ever, when you hit the publish button and hope for the best. Everything went well. "BMI Master" appears on Google Play Store within like 30 mins or so. 

Here's the link from Google Play Store: BMI Master


Here are some technical details:
Android Studio : 2.1.3
BitBucket - Git Version Control System, allows private repository up to 5 users (since I am the only one, that works well for me)
Fabric: Crashlytics - I used it to track any issues using the App. so far so good.
Fabric: Mopub - I used it for Banner and Interstitial Ads. I also linked up Admob in Mopub. I am using the marketplace feature for now. I am still learning, not 100% sure what I am doing :). Ads from marketplace has been showing up.
GreenRobot:GreenDAO - Android ORM for SQLite DB.
GreenRobot:EventBus - Event Bus.

Thats pretty much all you need to create this app. 

This is the first App that I wrote to try out the App market, I have so much fun working on it. It feels really good to be able to put your app out there. There are more apps that I plan to publish. 

Please download it and give it a try. 






Android App - "Dog Food Calculator"

11/16/2016

So this is my second Android App that I put on App Store. My first app was calculating BMI for Adults, Kids and Infants. I don't expect a lot of downloads or install with these apps. It was a lot of fun working on it and it doesn't take that much time to do. I spent about approximately 2 and a half week to finish this app.

Here's the link from Google Play Store: Dog Food Calculator


This app calculates the food requirements for your dog based on the energy (calorie) needs to maintain a healthy weight for their life stage. The calculation depends upon their energy and activity level. What I have added that I don't see from other dog food calculator out there is that it allows you to put in the dog food information like KCal/Cup, KCal/Kg, Bag Size, Price / Bag. Based on these information, I calculate the amount of food needed for your dog (Cups / Day). I also calculate the Cost / Day and how long will the bag lasts.


I thought it would be fun to add the dog breed list and used their min & max weight to calculate the costs based on the energy / activity level that user has chosen. I wrote some scripts to collect the dog breeds information that I think is fun from the internet. I added a Dog Breed Details where it allows you to change the weight on the fly and it calculates the cost based on the Energy / Activity level that user has selected.


I also thought it would be good to have it translated into Spanish and Chinese. I basically use Google Translate and since I don't speak Spanish, I rely on my friend to review the translation. As for the Mandarin, I did it myself even thought I am not very good at it. I was quite impressed with Google Translate, I wouldn't have thought of using some of the words if I were doing it myself.


Here are some technical details:
Android Studio: 2.1.3
BitBucket - Git Version Control System.
Fabric: Crashlytics - I used it to tract failures.
Fabric: Mopub - I used Banner and Interstitial Ads.
GreenRobot: GreenDao - Android ORM for SQLite DB.
GreenRobot: EventBus - Event Bus.
Proguard: Obfuscate android code.

It was a lot of fun working on this. I am working on a third App now.

If you have a dog and you don't really know how much you should feed your dog? Please download this app and give it a try. Your dog might be starving :).


Android App - "Tip Calculator"

10/16/2016

My third Android App in Google App Store. I spent approximately 1 week to finish this app, just doing it after working hour. So within like 2 months, I was able to publish 3 apps in total. Even though they are all simple apps but it does take some time to make them look good (at least to my standard).

"Tip Calculator" is what I wanted to create from the very start. I never like the job to split the bill at the end of a lunch gathering with friends / coworkers, coz it feels like I have to showoff my quick math skill that I don't necessarily possessed. It can be a bit stressful for me at times.

I don't like most of the tip calculator out there and I thought I can make a better version of it within a very short time. So this app is totally "Free" to download and there is No bloody Ads.

Here's the link from Google Play Store: Tip Calculator



This is mainly for users in United States because tipping is a culture here. We never really tip back in Malaysia and I did embarrassed myself once in Japan. It was my first time in Japan and eating in a restaurant by myself. At the end, I left some tips and left. The waitress chased me down the road and gave me back my money thinking that I left it accidentally. Japanese are super honest and what a great country.

Anyway, tipping in the US... I don't necessarily agreed with paying tips based on the total bill after tax. Most of the suggested tip amount that you saw at the bottom of the bill are calculated based on the after Tax value. I know many people still do it as they think that the difference is so insignificant. I do it sometimes too depending on the amount. But like my friend "Dennis" always says: "5 dollar is 5 dollar...". There are times you need to be generous but not always.

So this app actually let you have the option to include / exclude the tax calculation. Like my previous apps, I translated them into English, Spanish and Mandarin.



If you have the same problem like I did splitting the bills, try this app and I hope it will make it easier for you :). Please give this app some likes too.




Monday, December 21, 2015

TreatMaster V-2 - Enhanced Remote Dog Treat Dispenser powered by Raspberry Pi

Introduction

This project was completed earlier in 2015, but I am only now blogging about it...I didn't want to wait till 2016 to get a post up!

I created TreatMaster V-2 during March 2015. It is a Remote Dog Treat Dispenser that you can control from your mobile phone. It is powered by Raspberry Pi. I wrote an iOS App for it as well. Read on if you wanna know more. If you want to see the demo, press play below. 


To watch a better quality video, please click here.


Inspiration

It all started with this post (Judd-Treat-Machine) that I saw online a few years back. It inspired me to start working on Raspberry Pi. What a nice idea to be able to give your dog a treat when he is all alone at home by himself, while you are out having a good time with your friends. A few days later, I bought myself my first Raspberry Pi Model B+ along with a bunch of components so I could start playing with it. 



I built the TreatMaster V-1 prototype (similar to Judd-Treat-Machine) earlier in 2015. The prototype was a bit ugly but it worked. They way it works was: 
  1. You send Mac an email (Yes, Mac has his personal Email) with the subject "Treat".
  2. The treat machine gets the email and will called out for Mac to get him all excited and come towards the machine. 
  3. The machine then dispense the treat, while Mac enjoys his treat, the web camera takes a photo of Mac and replies with a thank you email back to the sender. 
Pretty neat huh! It worked and I was having so much fun making it...Read up more if interested in looking at TreatMaster V-1. The end product looked like this.



After successfully creating that, I just couldn't get myself back to working on it again. 

Early this year, I completed the 2 player bartop Arcade Game Machine, and still with high momentum, I thought it will be a good time to build TreatMaster version 2. This time, I wanted to make it a lot better, where I would be able to see Mac live in action while he is taking the treat, and I want to be able to talk to Mac. So I begin to work. 

How do I start?

I tore down TreatMaster Version-1 to reuse some of the components. I did away with the web camera and got a Raspberry Pi Camera Board. The big chunky plastic container that I got from Walmart had to go. I went to Michael's and got a pretty good size box that I could modify to fit my use. I kept the relay circuit, motor, speaker and auger bit. I am pretty much good to go!

This is the TreatMaster V-2 Architecture:

Software 

Backend Service - RESTful API Server

Date: 11th April 2015, I installed 2015-02-16-raspbian-wheezy.img OS on Raspberry Pi.

Lets keep this high level, I won't go into much boring technical details. 

The first thing I focused on was software. I want to be able to remotely communicate with my raspberry pi that connects with the other hardware parts. What's better than running a RESTful API Server with Flask-RESTful that exposes APIs to control the raspberry pi. I wrote the API Services in Python, example of APIs are:
  • API to establish connection, once connected, security token is exchanged and all subsequent communication is done with the temporary token.
  • API to start/stop the video steaming. 
  • API to upload/play audio.
  • API to take photo.
  • API to dispense treats.



Note: The video streaming is actually recursive photos that kept refreshing on the webserver, it creates an illusion of video when you load it up on your browser. That was how old civilian cameras used to work (if I am not wrong).






Interested into more details? Here are the references to:

  • Install Audio
    • Command to bring up volumn configuration GUI: $ alsamizer
pi@raspberrypi ~ $ sudo apt-get install python-pip
    • After pip is installed, you can use it to install Flask and its dependencies:
pi@raspberrypi ~ $ sudo pip install flask

How does the machine dispense treats?

It uses an Auger Conveyor approach where a rotating helical screw blade moves granular materials, in this case...Mac's treat. This is the same item I used for my TreatMaster V-1. I used GPIO to trigger a relay switch that would rotate the blade for a specific duration to push some treats out of it's container.




Raspberry Pi has 17 GPIO pins (General Purpose Input / Output) that allows you to send Input or Output signal to the board. The pins are 3V3 and not 5V, they directly connected to the Broadcom chip. It has a good chance of frying your Pi if you send >3V down the pin.







This is the Relay Circuit that I used to control my Motor along with the components that I used.








Mobile App Client

Once I had all the API working, I started to design the app. I sketched it on a piece of paper before working on the User Interface. Here's my sketch.



I wrote the code in iOS since I have a MacBook and use an iPhone. Here are the progress and changes:

Initial development

Finally, I am satisfied with this version where it is clean and simple. 


Hardware

I am not a handy man for sure. This is the toughest part for me and took the most time. I tried my best to make it as neat as possible. But still, it could have been better. 



I measured it out and made a cardboard container just to see how it will turn out. It seems to fit well. So the idea is to put the small dog treats into the green container and the Auger bit will rotate and push the treat out. This part needs a bit more work at this moment, it is not working 100% smoothly as I wanted it to. Once I got the cardboard measurement right, I bought some cheap perspex and made a solid container.



The box I got from Michael's is slightly thin. It didn't look like it is able to hold my motor securely. As a result, I glued another piece of wood at the bottom so that it is lifted and thicker for me to screw and secure the motor. After that, more wood filler and sanding... and filler and sanding...


After about 10 times of wood filler and sanding.... I am finally satisfied with the result, so I start painting. I applied about 3 layers of white prime just to be sure (I know it is a bit over kill but I have way too much prime left), then I applied the paint that I have left over from the Arcade Machine. By this time...you would have thought I have master the skill of painting...I still struggle to get the paint spread evenly. I am blaming the paint brush for sure :)



So finally, after a few days of painting. I put all of them together and thought it could be better. With my skill and effort, I am satisfied with that. 



Mac got excited every time TreatMaster make a sound. He got a bit scared and unsure at first, but he is doing a lot better now and got used to this machine.

This is not the last of it. I do have plan to work on Version-3. I didn't really keep track of the cost since I am using the stuff that I already got but my guesstimate would be around $80. I could probably make it a lot cheaper. Who knows, I might be making this and selling it one of these days...