Code Archives - Falafel Software Blog

Getting Started With Electron and TypeScript

By | Desktop, Electron, JavaScript, TypeScript, Web | One Comment

What is Electron? ElectronJS is a cross-platform app framework that allows you to leverage existing knowledge of JavaScript, HTML, and CSS to build apps for Windows, OSX, and Linux using a shared codebase. It is based on Node.js and Chromium and is used by many popular apps such as Visual Studio Code, Slack, and the Atom editor. If you haven’t already, install the Electron Prebuilt package from npm:

What is TypeScript? TypeScript is a typed superset of JavaScript that compiles into plain JavaScript. It is an easy way to simplify large complex JavaScript codebases or ensure integrity when working…

Read More

A Simple Natural Sort

By | .NET, C# | 5 Comments

If you’ve ever had to sort alphanumeric data, you’ve probably encountered the issue of sort order when letters and numbers are mixed. Here is a quick example:

The first set is using a standard ASCII sort which is sorted correctly, but not what most people expect–shouldn’t a2 come BEFORE a11? What they want is a natural sort which treats letters as letters and numbers as numbers rather than treating everything as an individual ASCII character. There are PLENTY of natural sort solutions out there and some may work better for your particular situation, but I came up with a simple natural…

Read More

Ionic and Material Design, what’s the story?

By | Android, AngularJS, Cordova, CSS, HTML5, Ionic, iOS, JavaScript, Mobile, News | 4 Comments

Ionic is considered one of the most advanced HTML5 Mobile App Development Framework for building hybrid mobile applications. Ionic Apps are based on AngularJS and Cordova, and the framework’s components allow developers to create great looking mobile apps that could match their native counterparts. While Ionic equally supports iOS and Android, the development experience (and issues) slightly diverge between the two platforms. In this article, we are going to focus on Ionic and Material Design. Background Ionic 1.0 was released in May 2015. Since its inception, the platform incorporated the concept of Platform Continuity which translates into Platform-specific styles. This means that developers focus on building beautiful apps which…

Read More

Heart Rate Display with a Photon and a Microsoft Band

By | .NET, Blogs, C#, Fun, IoT, Microsoft Band, Mobile, Multi-Device, News, Photon, Visual Studio, Windows Phone | 4 Comments

Those who know me, know I love sensors, and doing things with sensors. I’ve published many posts on accessing the various sensors on the Microsoft Band: Accelerometer & Gyroscope, Ultraviolet, Skin Temperature, and Galvanic Skin Response. One subject that I haven’t gotten to is the heart rate sensor. I’ve also started to publish a few IoT posts. For this post, I thought it would be fun to integrate the Band’s heart rate sensor with a Particle Photon so you can visualize your heart rate with an RGB LED. The LED pulses at the same rate as your heart and will shift…

Read More

Using Azure DocumentDB with Cordova Tools in Visual Studio (or any JS client)

By | ASP.NET, Azure, Cordova, HTML5, iOS, JavaScript, Microsoft, Mobile, Multi-Device, News, node.js, Tools, Visual Studio, Web | 4 Comments

Abstract A few weeks ago, I set on a mission to learn more about Azure DocumentDB. My end goal was to use Azure DocumentDB with a JavaScript client application specifically with a Cordova app built with the new Tools for Apache Cordova or TACO which the team introduced a while ago. Background In April 2015, Microsoft officially released DocumentDB, its cloud, document oriented, NoSQL database (It was in preview since 2014). Azure DocumentDB, a new player in the NoSQL market, is built to work within the Azure Cloud ecosystem much like SQL Azure, SQL Storage, Azure search, etc. You would use DocumentDB…

Read More

Controlling an RGB LED on a Photon with a UWA Color Picker

By | .NET, Blogs, C#, Fun, IoT, Microsoft, Mobile, Multi-Device, News, Photon, Visual Studio, Windows Universal Apps | 3 Comments

The Particle Photon makes it easy to control the color of an RGB LED. There are a number of color picker controls you can use in Windows apps. I wanted to see how easy it was to hook a Photon RGB LED up to a Windows app color picker. It ended up being a snap by using the Particle cloud functions. In this project I wrote a simple UWA that calls a Particle cloud function called “setRGB” on my targeted Photon whenever I change the selected value on the color picker. Then I implemented an event handler on that Photon’s…

Read More

Exploring Multi-Photon and Particle Cloud Functionality with a Useless Machine

By | .NET, Blogs, C#, Fun, Hardware, IoT, Microsoft, Mobile, Multi-Device, News, Photon, Visual Studio, Web, Windows, Windows Universal Apps | 2 Comments

There are many ways for Particle Photons to interact with each other. Even more ways for other devices and apps to interact with Photons through the Particle Cloud. To explore these capabilities, I created a useless machine. My useless machine is made up of two Photons. Photon 1 “falafel_1” has a photo resistor and a green LED. Photon 2 “falafel_2” also has a photo resistor and a green LED. However, Photon 2 also has a servo motor and a second red LED. The servo motor is mounted so that when it is rotated to 90 degrees, it covers both photo…

Read More

Windows IoT Core Remote Wifi Scanner

By | .NET, C#, Fun, IoT, Microsoft, Mobile, Multi-Device, News, Visual Studio, Windows, Windows Universal Apps | 3 Comments

Windows IoT Core has a nice web-based device management interface. This app can configure many aspects of the device, such as connecting the device to a WiFi network. Because the web-based device management was just a web app, I thought it shouldn’t be difficult to write a remote app to do the same. I ended up with a remote app that could query WiFi networks visible to a Windows IoT Core device and connect or disconnect that device to those networks. To get started, I connected my browser to the web-based device management app for one of my Windows IoT Core…

Read More

Using Application Insights with Cordova Apps in Visual Studio

By | Azure, Cordova, CSS, Fun, HTML5, iOS, JavaScript, Mobile, News, Tools, Visual Studio | 3 Comments

Abstract When developing a mobile application, native or hybrid, we require a certain way to monitor and track different activities and events in the application. Developers need to detect issues, solve problems and continuously improve the application code. Marketers, on the other hand, want different kind of metrics. For instance, they want to know how many people are using the application on a daily basis, what features they are using and how they are interacting with the application. Background Application Insights is a set of services that provide actionable insight into a production application. It monitors your application to detect issues,…

Read More

Sitefinity Asynchronous Search with WebAPI

By | .NET, ASP.NET, C#, Fun, HTML5, JavaScript, Kendo UI, Sitefinity, Telerik, Web, Web API | One Comment

Overview Sitefinity CMS features a powerful internal Search Engine that allows your site visitors to search your content and find what they are looking for. The Search Engine is built on top of the .NET port of the infamous Lunene Engine which powers an unlimited number of websites today. Unlike the solid Search Engine behind it, the Search Widget which Sitefinity offers is not as mature. It provides the options to set up a basic search page and returns the results in a form of a list. Perhaps that will be satisfactory in most cases, but what if your requirements exceed…

Read More

Microsoft Band Sensors – Accelerometer & Gyroscope

By | .NET, Blogs, C#, Fun, Microsoft, Mobile, Multi-Device, News, Windows | 11 Comments

Microsoft just released the Microsoft Band SDK Preview and I’m excited. Just like with any other electronic gadget, I’m interested in the sensors. The Band is stuffed full of sensors, but the first ones I want to look at are the accelerometers and gyroscopes. From the preview site you can download samples for Windows Phone, Android, and iOS. You also need the documentation. To get started with my sensors investigation, I downloaded the Windows Phone sample code and followed the instructions here to get started with my own project. Accessing the accelerometers and gyroscopes is easy and follows a familiar…

Read More

Data Annotations & Entity Type Configuration

By | .NET, C#, News, Web | 3 Comments

We can replace Data Annotations with Entity Type Configuration to make our classes look clean and simple. Majority of developers prefer using View Models for CRUD operations leaving no reason to have Data Annotations defined in our model classes. This article will show you how to replace Data Annotations with Entity Type Configuration when using Entity Framework Code-First.

Read More

Displaying the Device Compass in Unity

By | .NET, Blogs, C#, Fun, Mobile, Multi-Device, News, Unity, Windows | 5 Comments

In my last Unity post we looked at integrating the accelerometers in a Unity app. In this post we look at integrating the magnetometer. A couple of years ago I published a magnetometer application in the Windows Phone Store. That app shows the magnetometer readings in 3D in relation to the orientation of the phone. The magnetometer sensor is how your device senses true north for the compass. For some devices (like my Nokia 1520), the Unity magnetometer API hides the 3D vector and only gives you access to the 2D vector “compass” data. I’ll live with that for now. In…

Read More
Falafel Blog

Microsoft OCR Library

By | .NET, Blogs, C#, Fun, Microsoft, Multi-Device, News | 2 Comments

Microsoft recently announced that their OCR Library for Windows Runtime has been released as a NuGet package. This library enables you to add text reading capabilities to your Windows Phone 8/8.1 and Windows 8.1 Store apps. I wanted to get a simple working example up and running and found it to be quite easy and functional. I created a basic Windows 8.1 Store app. The XAML for the main page is listed below.

The code behind has only one event handler for the button click and because this is just a simple working example contains all of the code necessary…

Read More

Entity Framework and Enum Flags

By | .NET, C# | No Comments

If you have ever had the need to store one or more possible values in a single field, you may have used the [Flags] attribute on an enum in C# which would look something like this:

The numeric values that we assign are important, because it allows us to do bit-wise operations on the number.  The values themselves can easily be calculated by raising 2 to the power of a zero-based sequence of numbers.  So this: 2⁰, 2¹, 2², 2³, 2⁴, 2⁵, 2⁶ yields this (yes, 2 to the zero power is one): 1, 2, 4, 8, 16, 32,…

Read More
Page Selector

Sitefinity: Page Selector Field for Multisite

By | .NET, C#, News, Sitefinity | No Comments

Multisite is a great feature in the Sitefinity, which helps you centrally manage multiple sites using one administration panel. Few days ago I was working in a same environment where I needed to add a Page Selector field to a custom module built using Module Builder. But we needed to make Page Selector field to show pages from the current site. As it takes a rootNodeId (GUID for root page node) so it shows same pages under provided id. So, we needed to make it dynamic so that it would load pages from the current site.

Read More
Adding Document Selector Field

Document Selector Field in Sitefinity

By | .NET, C#, Sitefinity, Web | No Comments

Sitefinity Thunder lets you create field controls very easily which can be added to custom modules. However some work is required particularly when you need to have a selector field. Recently I built a Document Selector field control so I thought to share it. The purpose of this selector is to allow single document selection and be added as a text field (localizable).

Read More

Multi-Device Hybrid Apps… Custom Plugins

By | .NET, iOS, JavaScript, Microsoft, Mobile, Multi-Device, News, Tools | 8 Comments

Abstract If you are starting a project and ready to add a few Cordova API plugins, you have many choices to choose from. If you’ve tried to add a custom plugin to your Multi-Device Hybrid app, you might have noticed there is no easy way to do that. In this post I will show you how that can be done. Background Cordova has moved into a modular design starting with version 3. For example, to call the device.version API, you need to include the Device plugin into your project. It also supports two different ways to add and remove plugins, depending…

Read More

Picking your Challenges – Luminance for Points

By | .NET, Blogs, C#, Fun, Windows | No Comments

One of the things I’m learning as I’m settling into my #2520orBust challenge, is picking which challenges I’m going to tackle on DVLUP.com. You have to consider the requirements of the challenge and the due dates. You also have to consider the amount of free time you have to devote to the challenge. For me, that’s not much time. So, I’m looking at the low hanging fruit right now. The next challenge on my list is the “New App Special“. It’s 250 pts, and I’ve got until the end of August. The app I have in mind is a lux…

Read More

Multi-Device Hybrid Apps… Where are the iOS and Windows Simulators?

By | .NET, C#, iOS, JavaScript, Kendo UI, Microsoft, Mobile | 2 Comments

In a previous post we have discussed how we can build and run the multi-device hybrid apps in a simulator for Android and we also demonstrated how we can build and deploy the application to a physical device. If you’ve recently upgraded your Visual Studio 2013 to Update 2, you might have noticed that there is no way for you to simulate the application in iOS whether in an iPad or an iPhone. The current version of Cordova tooling in Visual Studio claims to support multiple platforms which is a fact. In this column I will show you how you can add…

Read More

It’s Tuples All The Way Down!

By | C# | No Comments

Tuples in C# provide developers with a quick way of creating data structures without the need to define a separate class, but they should be used with caution. I’ll demonstrate when you should–and shouldn’t–use tuples. Spoiler alert: I do not recommend the code in the adjacent image!

Read More

Running Cordova Multi-Device Hybrid App from Visual Studio On Android Device

By | .NET, Android, C#, Icenium, JavaScript, Kendo UI, Microsoft, Mobile, MVVM, Telerik, Tools | 15 Comments

As the name suggests, in this column I am going to show you how to run and debug your hybrid application from Visual Studio on your Android device. We will not be covering iOS here but in a later post. If you haven’t started developing Multi-Device Hybrid applications in Visual Studio then I suggest that you take a look at my previous post. If you have attempted to run your application on your Android device and you were not successful, read on. First of all, to run your application on your device, you need to select the “Device” mode in Visual…

Read More

Getting Started with Cordova and Multi-Device Hybrid App in Visual Studio

By | .NET, Android, iOS, JavaScript, Kendo UI, Microsoft, Mobile, Tools, Web, Windows | 18 Comments

Two days ago at TechEd conference, Microsoft announced the future step in its “mobile first, cloud first” strategy with a preview of Apache Cordova support in Visual Studio. Apache Cordova is a popular open source toolkit for building apps for iOS, Android, and Windows using HTML, CSS, and JavaScript. With the Cordova integration, Visual Studio will directly support building apps for all of these platforms. The Cordova support is important for a number of reasons. It very much aligns with the company’s strategy to target all the platforms and provide the developers with the tools to do it. After announcing the partnership with…

Read More