Posts

Showing posts with the label Node

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...