Attach to Process

Thoughts and Notes on Software Development

In the parent React class component, you can declare a function, that you can then pass into one of its child components.

So say you had a <Form /> child component and a addNewProfile function. You can pass the function to the child component like so:

<Form onSubmit={this.addNewProfile} />

Then in the code for the Form component, you can get to the passed in function via the props object, like so:

 this.props.onSubmit(/*parameters go in here*/)

Note how React is smart enough to know that there would be an onSubmit property available in this.props. That's one of the cool things with React props.

So anyway, passing functions into child components is basically like passing a reference to a function. It's similar to how delegates work in C# and .NET.

Tags: #React

Coworker was getting a TCP error code 10061: No connection could be made because the target machine actively refused it [closed] error, while trying to setup an application to run in IIS.

The fix that worked for us can be found here: TCP error code 10061: No connection could be made because the target machine actively refused it windows 7.

The fix was basically to check the “Windows Communication Foundation Non-HTTP Activation” checkbox under .NET Framework 3.5 in the Windows Features settings box.

Tags: #WCF #TCP

Version 1.2.0 of WriteAs.Net has been released.

This latest version now allows you to enter an API key when initializing a WriteAsClient instance. This API key will allow you to bypass the rate limiting checks on the API.

Some basic in-memory caching has also been added to the client. You can configure some of the cache settings when initializing a WriteAsClient instance. The new settings are described below:

  • cacheExpirationInSeconds determines how long data will stay in the cache before it expires. The default value for this setting is 300 seconds.
  • cacheSize determines how many objects it can store in the cache. Note that a collection of posts (List<Post>) and a single post each count as 1 item. The default value for this setting is 4.

You can install it via nuget: Install-Package WriteAs.NET -Version 1.2.0

Or via the .NET Core command line interface: dotnet add package WriteAs.NET --version 1.2.0

If you find any bugs or issues with it, please let me know. Thanks and y'all have a good weekend.

Tags: #DotNet #WriteAs #WriteAsNet

I'm working on an update to the WriteAs.Net client/wrapper library. In a previous post I talked about adding caching to it before I release a new version. I ran into some road-blocks that derailed me. I ended up pushing it off to the side to focus my time somewhere else.

The two issues that I ran into were: figuring out what the cache key was going to be for the cached object and removing the oldest object in the cache. I now have solutions for those issues.

For the cache keys, I figured I could use the method name plus the parameter values.

For clearing out the oldest cached object, I decided to make use of a generic Queue collection that could accept the cache key values. Then I could just pop-off the oldest value from the Queue and use that to remove the associated object in the cache.

And so anyway, I should have the updated version of the client/wrapper library out soon. I just need to do some more testing on it.

Tags: #DotNet #WriteAs #WriteAsNet

On my Above the Earth and Seas photo-blog, I was able to add a link to get a random post using just plain JavaScript.

The reason this works is because I decided to use numbers for all the post slugs/urls. That allows me to use simple Math functions in JavaScript to come up with a random number. Then I use that random number to construct a url to link to. It's pretty basic but it works.

Here is the Custom JavaScript that I added:

// This number matches the url of my latest post
const latestIndex = 36;

/* Get random post */
const a = document.querySelector('a[href$="/random"]');
if (a !== null) {
    const randomIndex = Math.floor((Math.random() * latestIndex) + 1);
    const pad = '000';
    const randomPostIndex = (pad + parseInt(randomIndex)).slice(-pad.length);
    const randomPostUrl = '' + randomPostIndex;
    a.setAttribute('href', randomPostUrl);
    a.setAttribute('title', 'Get a random post');

Tags: #JavaScript

To get a list of the global config options for Git, you can run this:

git config --global --list

When setting config options, you need to add the location of the config file. So for example, if you want to set core.autocrlf to false as a global or system option, you can run either one of the following commands (depending on the location you want to run it for):

git config --global core.autocrlf false
git config --system core.autocrlf false

Tags: #Git

The git pull command is basically like “Get Latest Version” in TFS. It pulls down the latest changes for a repository and merges them into the local files in your computer.

I don't think there is an equivalent in TFS for the git fetch command. The closest thing to it in TFS is probably viewing history, then manually checking to see what changes you are missing. Or doing a merge of branches to see what is different.

In comparison to the git pull command, running git fetch will not pull down any changes. From what I understand, all it does is compare the changes/code in the remote repository with your own local repository. Then it can tell you whether your local repository is behind or ahead, as far as changes go, with the remote repository. This is even better than what you can do in TFS, because it allows you to see exactly what changes you don't have on your local repository.

Tags: #Git #TeamFoundationServer

A few months ago, I ran into a situation where I had to increase the timeout for a WCF service call, that my ASP.NET Web API was making. It wasn't as straightforward as just adding configuration to a config file, like you would do with a WCF service. You actually have to do it in code. The answers to the stackoverflow question listed below, helped a lot in figuring out a solution for it.

Link: How to increase the timeout values for a WCF service in a dot net core 2.1 project – Stack Overflow

In your Web API code, you can create a partial class for the WCF client you are trying to call. In that class, you should be able to get to the Endpoint object. This object allows you get to the WCF bindings where you can set the timeout values. Then you can do something similar to the code I have below to set the timeouts.

TimeSpan timeSpan = new TimeSpan(hours: 0, minutes: 0, seconds: timeoutInSeconds);
Endpoint.Binding.CloseTimeout = timeSpan;
Endpoint.Binding.OpenTimeout = timeSpan;
Endpoint.Binding.ReceiveTimeout = timeSpan;
Endpoint.Binding.SendTimeout = timeSpan;

Tags: #AspDotNet #AspDotNetWebApi #WCF

This is a pretty good guide to building a blog using ReactJS and Sanity. That said, I did run into a number of issues while trying to follow it. This post is about the issues I ran into and the solutions for them.

When I got to the part where it says to run sanity init, I got errors in Visual Studio Code saying the PowerShell script is not digitally signed, so it's not allowed to run. The fix for this was to run: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force in the VS Code terminal.

Then I got the error Error: self signed certificate in certificate chain. Looked it up online and found that it seems to be caused by my VPN connection. I disconnected from my work VPN and it did resolve my issue.

I got all the way to the part of the guide where I was Building the page for all the blog posts. After following the instructions and copying the provided code into src/components/AllPosts.js , I kept running into a post.mainImage undefined error. It turns out, the provided code is expecting all posts I created in Sanity to have a main image. I had one for my first post, but didn't add one to my second post.

The fix for the issue above was to replace <img src={post.mainImage.asset.url} alt="" /> with {typeof post.mainImage !== 'undefined' && <img src={post.mainImage.asset.url} alt="" />}.

What that new line of code does, is check if post.mainImage is NOT undefined, and if so, render the img tag. If it was undefined, as is the case with my second post, it wouldn't render the tag, thereby avoiding the error.

After finishing the guide, I needed to figure out how to deploy the React app to Netlify. Posts online say it is as easy as dropping a Build folder into Netlify. However, there's no Build folder in sight in VS Code. Turns out, I had to run npm run build to generate the Build folder and its contents. After that, it was as easy as dropping the folder into the Netlify's deploy folder. You can find the live site on here.

Initially the site would load, but the blog posts wouldn't show up. The fix for this was to add the site url,, as a CORS Origins entry in my Sanity account's API settings.

Tags: #React #Blog #Bookmarks

Extremely good read on how to advance in your career as a software developer. While this guide was mainly written for Junior software developers working at medium-large companies, I reckon even Senior software developers can learn a thing or two from this guide.

Link: Leveling Up: Career Advancement for Software Developers

Tags: #Bookmarks #Career

Enter your email to subscribe to updates.