Posts

Testing Angular Directives with Karma, Mocha, and Phantom

All Code on Github The entire code from this article is on github . Introduction Angular Directives are part of the web part/components group of client-side  tools that allow quick additions to web pages. The idea is that with a very simple and short addition to an html page, complex functionality and UX are available. Imagine a user login form with the traditional validation contained in a html template and Angular controller. The main, calling web page’s html could just include <login></login> to bring in that rich validation and display. Directives are wonderful for encapsulating the complexity away from the containing HTML. Testing the directive is trickier. Granted the controller isn’t difficult to test. But the compiled html and scope are not so easy. Perhaps it is enough to test the controller, and depend on the browser and the Angular library to manage the rest.  You could definitely make that case. Or perhaps you leave the compiled directive ...

Capturing a Stripe Credit Card Charge

Image
In this article, I'll show you the JSON objects and Angular/Node code to capture a credit card with the Stripe service . The code for this example project is on GitHub . It is a working project so the code may not be exactly like this article by the time you find it. Introduction Capturing credit card information for products, services, and subscriptions is easy with many tools provided by credit card processing companies. Stripe provides an html button that pops up a form to collect credit card information . It is incredibly simple and straightforward. You can control the form to collect more data. You don't need to know how to program it, and it works. Yeah! This article doesn't cover the easy route of button and pop up because Stripe did a great job of that on their website . If you would prefer to control the credit card experience from beginning to end, you may choose to build your own form and process the data you collect to meet your own business needs. I...

Extending a linux web dashboard

Image
Adding pm2 status to linux-dash linux-dash is a light-weight, open-source web dashboard to monitor your linux machine or virtual machine. You can find this package on Github . The dashboard reports many different aspects of our linux installation via shell scripts (*.sh). This allows the dashboard to be light-weight, and work on most linux machines. The website displays running charts, and tables. The web site can be node, php, or go. For the node webserver, the only dependencies are express and websocket. Extending linux-dash You may have a few extra services or programs running on your linux installation that you would like to display on linux-dash . I use pm2 , a process manager. Adding a table to display the pm2 status information was very easy -- even if you are not familiar with client-side Angular directives or server-side Node.JS or server-side shell scripts. The naming convention and templating allows us to focus on the few components we need to build without st...

Prototyping in MongoDB with the Aggregation Pipeline stage operator $sample

Image
Prototyping in MongoDB with the Aggregation Pipeline stage operator $sample The World Map as a visual example In order to show how the random sampling works in the mongoDB query, this NodeJS Express website will show the world map and display random latitude/longitude points on the map. Each refresh of the page will produce new random points. Below the map, the docs will display. Once the website is up and working with data points, we will play with the query to see how the data points change in response. The demonstration video is available on YouTube . Setup steps for the website Setup This article assumes you have no mongoDB, no website, and no data. It does assume you have an account on Compose . Each step is broken out and explained. If there is a step you already have, such as the mongoDB with latitude/longitude data or a website that displays it, skip to the next. get website running, display map with no data setup the mongoDB+ ssl database get mock d...

Frugal Cloud The In-Memory versus SSD Paging File

Image
Many people remember the days when you could use a USB memory stick to boost the performance of Windows. This memory caused me to ask the question: Is there a potential cost saving with little performance impact by going sparse on physical memory and configuring a paging file. For windows folks: For Linux, see TechTalk Joe post . Note his " I/O requests on instance storage does not incur a cost. Only EBS volumes have I/O request charges." so it is not recommended to do if you are running with EBS only. This approach is particularly significant when you are "just over" one the offering levels.  For some configurations, you will not get a CPU boost - by using the paging files. I know recent experience with a commercial SAAS actually had high memory usage but very log CPU (3-5%, even during peak times!). Having 1/2 or even 1/4 the CPUs would not peg the CPU. The question then becomes whether the Paging File on a SSD drive would significantly drop per...

Sharding Cloud Instances

Database sharding has been with us for many years. The concept of cloud instance sharding has not been discussed much. There is a significant financial incentive to do. Consider a component that provides address and/or postal code validation around the world. For the sake of illustration, let us consider 10 regions that each have the same volume of data. Initial tests found that it took 25 GB of data to load all of them in memory. Working of AWS EC2 price list , we find that a m4.2xlarge is needed to run it, at $0.479/hr. This gives us 8 CPUs. If we run with 10 @ 2.5 GB instead, we end up with 10 t2.medium, each with 2 CPU and a cost of $0.052/hr, or $0.52/hr -- which on first impression is more expensive, except we have 20 CPUs instead of 8 CPU. We may have better performance. If one of these instances is a hot spot (like US addresses), then we may end up with  9 instances that each support one region each and perhaps 5 instances supporting the US. As a single instance model...

An Financially Frugal Architectural Pattern for the Cloud

Image
I have heard many companies complain about how expensive the cloud is becoming as they moved from development to production systems. In theory, the saved costs of greatly reduced staffing of Site Reliability Engineers and reduced hardware costs should compensate -- key word is should.  In reality, this reduction never happens because they are needed to support other systems that will not be migrated for years. There is actually another problem, the architecture is not designed for the pricing model. In the last few years there have been many changes in the application environment, and I suspect many current architectures are locked into past system design patterns. To understand my proposal better, we need to look at the patterns thru the decades. The starting point is the classic client server: Many Clients - one Server - one database server (possibly many databases) As application volume grew, we ended up with multiple servers to handle multiple clients but retaining a s...