Category: Geek Stuffs

So I decided to move my blog from shared hosting so VPS hosting. VPS is getting cheaper everyday with as low as $2 per day makes it a good bargain to host blog in VPS. With VPS, we can choose which software we want to install, and configure it in our own taste.

But definitely, choosing VPS is not for everyone. It is more suitable for advanced user as configuring it involves a great deal of IT skills. Despite of several one-click install available which makes our VPS production ready within few minutes, configuring manually enables us to cramp our VPS and maximize the resource without several overhead and bloatware provided by one-click install. Moreover, I believe it is a good step for us to get to know how to deploy server for production grade.

The Problem with Previous Hosting

Actually I experienced no major issue with my previous hosting. But from recent review, I read a lot of complaints and recommendation to stay away from this host anymore. My previous hosting was shared Windows hosting. I used to experiment with Windows hosting to host ASP.NET application but for most of the time, I am using it only for hosting my blog. Moreover, nowadays there is a technology called ASP.NET Core which can be run on top of Linux machine. Therefore, I have no constraint in using Linux again for deploying my own personal server.

Moving to Linux VPS will be a new experience for me as I will ditch the simplicity of configuring and deploying sites via IIS Management console and Visual Studio. I also have to install and configure on my own via command line. But I think it is a great idea to learn and build your own server from scratch!

Advantage of VPS

We can configure VPS to suit our needs. We can also install software other than web server, such as streaming server, messaging server, etc. This ability is unavailable in basic shared hosting services. You are also not limited by specific platform, such as PHP, which is really common in shared hosting. You can pick your favorite platform and install it.

I was building a combination of operators which accepts a lot of literals and temporary objects including lambda. So for instance:

auto res = ObjectA() * ObjectB() + ObjectC() * ObjectD();

Based on the precedence rules, ObjectA will be ‘multiplied’ with ObjectB, then ObjectC will be ‘multiplied’ with ObjectD, then the result object of those two will be ‘added’. Notes that the order of multiplication is decided by compiler.

So the thing is, inside the overloaded multiplication operator, I want to store the temporary ObjectD, for instance, then carry it over on the addition operator later on when executing the ‘add’ operator. To achieve the “efficiency”, I store the ObjectD temporary inside an rvalue reference so it can be accessed “efficiently” during the execution of the ‘add’ operator.

It’s pain in the ass. Really. If you can stick to Ubuntu or its derivatives, please do that.

I kinda hate how Tizen Studio is developed to only support Ubuntu out-of-the-box. A software should not dictate what Linux distro it should be installed on. Distro is just like a religion for some people, and some people are like me, who doesn’t like Ubuntu and its bloatware.

Personally I use OpenSUSE on my home workstation, and Fedora on my office workstation. Both distros are RPM based and it is really difficult to install Tizen Studio which is tied to Ubuntu (which relies on Debian Package).

Installing Tizen Studio in Fedora and OpenSUSE is basically similar: it nags every single time. Firstly, Tizen Studio requires Oracle JDK. So for a system with OpenJDK by default installed, you have to install Oracle JDK then change the default Java to Oracle JDK. I am not sure why Tizen Studio forces us to go for Oracle JDK instead of OpenJDK as there might be only subtle differences between those two. Even this Stack Overflow thread said so.

I have been dealing with Tizen development since about last year, and since then I have been learning of utilizing C++11 features on my codes. Currently I am developing a some kind of component to help performing message pump in threading, so you can dispatch a function to a queue to be performed in separate thread.

It is a simple components actually. You can take a look at GitHub. DispatchQueue class basically accepts functions to be queued to be executed in another thread. I uses std::deque to queue the tasks, and std::function to store lambda or other callable objects. To support the threading, I uses std::mutex for synchronization, as well as std::condition_variable to suspend thread during empty queue.

The code compiles flawlessly, but when I tried to run a Tizen native app using this component, the app directly crashed upon starting the DispatchQueue class. The worst part was that the call stack in crash log does not show that it was crashing in user code, but it shown that the signal was SIGABRT so it might be caused by an unhandled exception.Continue reading “Weird std::thread bug on GCC 4.9 on ARM target”

I am tinkering with Raspberry Pi 3 (RasPi) and Windows 10 IoT Core. I was thinking how to build an IoT device with GPS functionality in RasPi. Many IoT projects employ GPS module but they use it mostly with Arduino to build quadcopter. Some people tried it with RasPi, but they use it in Raspbian OS. No one seems tried to build directly with RPi and Windows.

So, I made my own implementation, a library to connect Windows apps with GPS device. Long story short, you can make Windows app running on RasPi which utilize GPS, and you can code it on C#.

Check the code on GitHub. The library is licensed under GNU Lesser General Public License v3. You may use it in your project while retaining the license and credit to me. 🙂

How To Use

You just simply to download the binary release, or compile it on your own. Then add reference to Heliosky.IoT.GPS.dll in your project.

To use the library, you can add usings below to simplify the class resolution.

It’s been a while since my last post. With this post, I would like to share a little bit of my toolkit which I use extensively on my Android project. 🙂

Overview

So basically, when you are developing apps for Android, you use Android XML file to define the User Interface (UI) layout structure, then you code using Java for the implementation. Basically they resembles the .NET WPF/Silverlight’s XAML development, which they also use XML file to define the UI layout. But the worst thing I hate in the Android implementation is that basically the XML file and the Java code behind doesn’t really integrated seamlessly.

What made me say that .NET XAML is far years ahead compared to Android XML layout file? See the difference between those two frameworks below. Example: I want to make a simple WPF application containing a text box and a button. The button will be set disabled immediately after clicked, and show message box containing the text in the text box.

NET Framework WPF

In .NET Framework, the XAML file is seamlessly integrated with the code behind. In XAML you can define a Name for each of your control (widget), and call it directly from the C# code behind using the defined name

Android

To perform the same task in Android, you have to call findViewById for each widget ID defined in the XML layout file, and cast and store the returned value from the function call to the instance variable. This leads to messier code compared to .NET style, because you have to call and assign every reference in code behind before you can access what is defined inside XML layout file. Basically you do the integration between XML layout file and code behind manually.

Idea

I want Android to have similar capability like .NET Framework which I don’t have to assign the reference to the widget manually by calling findViewById on each widget. This is to simplify the code and to make the code cleaner.

Overview

So I got a task in designing a scalable and modular Service Oriented application using JSON and WCF. I am designing a web service using WCF. The communication between the web service and the client will be using JSON. While the server is using .NET Framework, the client is using Android Java. I aim to design the service as modular as possible. For every web service request from the client, the server will return the response in some kind of “envelope”. The “envelope” contains the execution result, whether it is success or not, the text message from web service, and the attachment which may contains object of specific type as the result of the service call.

I want to develop the modularity in my service framework, where I can make the “envelope” object as generic object that accept any kind of attachment type. And I want to deserialize the JSON response from server in my Android directly into specified “envelope” and attachment type, so that I can use it fairly easy in my code.

I’ve been using Entity Framework since its introduction. Entity Framework (EF) is a powerful Object-Relational Mapping (ORM) framework for .NET Framework. I’ve been debating with my teammates whether EF is better than other ORM such as OpenAccess, which I believe is true, because EF provides the necessary feature to connect our program to the database, especially if you are using Microsoft products, SQL Server. In my thinking, why bother using custom ORM to connect to SQL Server while actually Microsoft, the creator of everything (well, not, only .NET Framework and SQL Server I’m talking about here) provided the powerful tools to support your needs. In fact, Microsoft fully support the EF and provides the latest features as their development (EF and SQL Server) (should) inline each other.

Ok, I’m not going to debate about which one is better. I am going to talk about Code First approach to build your model from scratch. This is the first time I am trying using Code First approach, while previously I always use Database First or Model First approach.

Ways to Model Your Database

Entity Framework has been evolving quite rapidly. In the newest version, I noticed they are now using DbContext class instead of the old ObjectContext. And the new generated classes (if you are generating the model from existing database), will be just Plain-Old-CLR-Objects (POCOs). In previous EF, all the model classes must be derived from EntityObject. This offers more flexibility in designing your model classes.

One other notable changes I found is that the entity framework do not require the resource file definition in the connection string anymore. This will offer more flexibility in porting your model into separate DLL library and reuse it wherever you want. I am going to explore this finding later.

Previously I told about achieving modularity in web application and I mentioned about using XML files as a configuration script for our module. This session, I’m going to explain the easy way to load external XML file to your program. This method doesn’t only work on web application, but in any .NET application.

Where to Start?

I usually start developing custom XML structure by typing directly to my XML file. It is some kind of prototyping your XML structure. In this case, I am going to develop an XML file that contains a configuration information for my modular theming system. The XML file will describe the theme description and theme structure which is a list of ASPX pages that is inside that theme file. For each pages in theme, they should contains the type of the page, title of the page, identifier, and ASPX file name of the page.

From that requirement, I could derive my new theme file is something like this: