Posts

Showing posts from 2017

Creating Buttons That Act Like Links in Angular

While working on a pet project in Angular tonight, I wanted to create some buttons that act like links. Turns out, this is easy -- just apply the routerLink directive to a button and it will act like a link. Here's an example:

<button class="btn btn-success" routerlink="/exercises/edit">Edit an Exercise</button>

A Weird Coincidence

Yesterday while heading out at lunchtime I saw someone who reminded me of an old coworker named Avi. I'd worked with Avi at two separate jobs, non-consecutively, and we hadn't kept in touch in between them, so it was an example of how small the world can be at times. When I saw this person yesterday who reminded me of Avi, I remembered how he'd had a good working relationship with one of our business clients named Jack, and how Jack had referred me to his brother Jeff when I needed to find someone to do some home improvement work for me. I haven't spoken to any of them in 4 years, and only ever spoke to Jeff once.

Today, while in a meeting shortly before lunchtime, my phone rang. It was Jeff.

I couldn't believe it. I hadn't spoken to him in years, he crossed my mind out of the blue yesterday, and today he called. What could this guy that I didn't really know and whom I'd only ever spoken to once, 4 years ago, for about 5 minutes, be calling me about? Be…

Where Everybody Knows Your Name

Image
The classic television sitcom Cheers tells us that "Sometimes you want to go where everybody knows your name." And when I was in my late teens and earlier twenties, there was a place like that where I spent a lot of my time. Only it wasn't a bar, it was a pool hall.

The Rack Room was located on Route 1 in Langhorne, Pennsylvania. It was located behind a Denny's with which it shared a parking lot. It was a pool hall (and a parking lot for that matter) in which I spent a lot of my free time.

I'd been introduced to the place when I was 16. I'd been working part-time at a grocery store and one of my friends/co-workers from there was a regular. I hadn't spent much time in pool halls up until that point, and truth be told I still can't shoot a very good game. I spent just as much time in the Rack Room's arcade playing the latest Mortal Kombat game as I did shooting pool But it wasn't as much about the pool as it was about having a place to hang out…

I-95 Marketplace Remembered

One of the staples of my youth was the I-95 Marketplace, an indoor fleamarket which was located in Langhorne, Pennsylvania. It was only open Friday through Sunday (adding Thursdays and eventually the other weekdays during the holidays), and the interior was a large, open space comprised of small shops separated by poles and canvas. You could find all sorts of products there, from clothing, electronics, toys, furniture, books -- pretty much anything.

I would typically go there Friday evenings after school. I'd walk through the woods behind my house, cross two sections of creek, walk under two sections of I-95 itself (the northbound and the southbound), before finally emerging from the woods and arriving at the back of the marketplace building. I have many vivid memories of making the trek in dark, rainy weather, often arriving with wet (or drenched!) sneakers and cuffs, sometimes muddy, but always ready to head inside and spend my allowance on comic books or music or whatever else …

How To Mock Out Child Components In Unit Tests of Angular 2 Code

I was struggling with this one for a bit but found a solution this past weekend. When writing unit tests of a component that contains child components, the solution is to do the following:
1.Create small mock classes in your test file to represent the child components and include just the functionality you’ll be mocking. These classes should have the @Component() decorator applied to them and contain selectors that match the real components they are being substituted for. 2.Specify these mock components in the declarations section of the object you’re passing to TestBed.configureTestingModule().
Example: ActivityMgmtComponent has a few child components. Here are two of them:
<activity-edit#viewEditActivity></activity-edit> <activity-history#viewActivityHistory></activity-history>
Notice the # values – these are there to support the @ViewChild decorator function. This allows the parent component to call functions on the child components.
@ViewChild('viewActivity…

"Arithmetic operation resulted in an overflow" Error When Retrieving Data From Oracle In .NET

I ran into this fun little exception today when calling a stored procedure in Oracle from some .NET code. The error message was "Arithmetic operation resulted in an overflow", and from what I was able to Google, it seemed like it was caused by a difference in precision between numeric data types in .NET and Oracle, or by the need to compile the code in 32-bit mode. But in my case, neither was the cause. When one of our DBAs suggested I try the same code using the simple "SELECT 1 FROM DUAL" query, and the exception still occurred, I began to look for other reasons.

Fortunately, it was an easy fix. The cause of the problem was actually a setting on the DevArt OracleCommand object being used in the .NET code. Here is the offending line of code:

command.FetchSize = int.MaxValue;
Removing this line of code corrected the problem.

Using Webpack to Bundle CSS with Images and Fonts

One of my teams at work is currently developing in Angular 2, and we use Webpack for all of our TypeScript transpilation, module loading, and bundling. Yesterday we ran into an issue where one of the developers had made references to CSS files located in the node_modules directory of one of the 3rd party libraries we're using. This presented a problem because we don't distribute the node_modules folder as part of our build and deployment process -- we use JavaScript bundles created by Webpack.

To correct the problem, I leveraged Webpack again, this time to bundle the required CSS files. The first step was to create a SASS file (.scss) which would be used as the entry point by Webpack. The reasoning behind using SASS was to allow us to do more than just reference the other stylesheets. But for the time being, it would do just that, and act as our entry point for Webpack to build its dependancy graph of our styles.

Here's what the SASS file looked like at the start:

@import&#…