Attach to Process

Thoughts and Notes on Software Development

Recently had need of a script that can tell me the time difference in seconds, between two DateTime values in SQL Server. Here is what worked for me:

SELECT DATEDIFF(S, StartDateTime, EndDateTime) AS DurationInSeconds;

Note the first parameter, S, tells the DATEDIFF function to return the difference in Seconds. You can pass in other values as well, like MS for milliseconds or HH for hours.

You can find out more about the DATEDIFF function here.

Tags: #Scripts #SqlServer

Discuss... or leave a comment below.

As part of learning React, I'm also trying to shore up my JavaScript skills. Thankfully, the React: Getting Started pluralsight course also offers a modern JavaScript crash course. These are my notes from when I tried to understand JavaScript's Destructuring feature.

Note that you can run the sample code on a JavaScript tester website, like say the JSComplete Playground.

So, the JavaScript destructuring assignment syntax allows you to get just the properties you want from an object. It seems to be like a shortcut for getting to the properties of an object. For example:

const customerInfo = {
	firstName: "Dino",
	lastName: "Bansigan",
	emailAddress: "myemail@email.com",
	website: "dinobansigan.com"
}

const getFullName = ({firstName, lastName}) => {
	return firstName + " " + lastName;
}

console.log(getFullName(customerInfo));

In the code above, you can see how I have created a customerInfo object. Then next is a function called getFullName that takes a firstName and lastName parameter. These parameters are destructured from the customerInfo object.

If you look at the last bit of code where I call console.log, you can see that instead of passing in parameters customerInfo.firstName and customerInfo.lastName, all I had to do, was pass in the customerInfo object. JavaScript through the destructuring feature is smart enough to know to use the firstName and lastName properties from the customerInfo object.

Read more...

Starting a new DevNotes series. This is a spin-off from my Weeknotes series. This one focuses on software development content only. This one won't exactly be a weekly thing. I'll only publish a DevNotes post when I have a number of notes to share. Otherwise I'll bundle them up into a bigger post and publish then. And with that out of the way, let's get started...

I'm starting to notice a trend with the Rust programming language. It seems to be the next big thing. Microsoft even joined the Rust Foundation. It probably should be the next language I should learn after React.


I just realized, after installing the React Browser Dev Tools Extension, that Microsoft's Azure DevOps site was built using React. If Microsoft, who created C# and ASP.NET, uses React on their core products, it is just one more reason for me to really dig into React.


React components can be thought of as building blocks for your website. Instead of creating a button then styling it with the primary-button CSS class, you create a PrimaryButton component then use it wherever you want.

Reference: Get to Know Gatsby Building Blocks


I was building a very basic Gatsby website, the one from their tutorial. It was taking too long to build the output for a static site. Too long compared to building sites using Wyam. I don't have anything against Gatsby. In fact I'm trying to learn Gatsby. I'm just pointing out that it seems slow compared to Wyam.


While going through the Gatsby tutorial, I found another alternative to Netlify for hosting static sites: Surge.

Tags: #DevNotes #Gatsby #ReactJS #Rust #StaticSiteGenerator

Discuss... or leave a comment below.

I am using the Lanyon theme on my micro.blog hosted photo-blog. I noticed that the Published Date was showing up on my about page. Here is how I managed to hide it using some JavaScript.

<script type="text/javascript">
var isAboutPage = /\/about\/$/i.test(window.location.href);
if (isAboutPage) {
  var x = document.getElementsByClassName("post-date");
  if (x) {
    x[0].remove();
  }
}
</script>

I added the script to the layouts/partials/default_foot.html file, just before the closing </body> tag.

This is a result of me playing around with Custom JavaScript on my write.as sites. I was able to carry over what I learned here and use it to fix something on another website. One of the best benefits of maintaining a personal website, is brushing up on your HTML, CSS and JavaScript skills.

Tags: #JavaScript #MicroBlog

Discuss... or leave a comment below.

My first attempt at learning the React JavaScript library was by reading the ASP.NET Core 3 and React book. I started reading that book a few months ago. I've gone through the first six chapters, which mostly covers how to build a web app front-end using React. While I did learn a lot reading those chapters, I was barely keeping up.

There's so many new concepts, new libraries, new methods, new syntax to learn. It felt overwhelming at times. It didn't help that I kept getting distracted at the JSX syntax — which looked insane to me at times.

I found myself simply typing what was in the book. But I actually couldn't tell you why the code worked. I was honestly struggling to keep up. But more importantly, I was confused and frustrated at it all. Why would you even want to go through all this trouble of writing a React app? I didn't get it. And consequently, I wasn't too excited to learn more. But I had to.

Read more...

If you're trying to publish a SQL Server database project using Visual Studio, but you're not seeing the Publish dialog box show up, check your other Desktop in Windows. I've noticed that every once in a while, the Publish dialog box shows up in another virtual desktop, instead of showing up on the one you're currently working on.

Tags: #SqlServer #VisualStudio

Discuss... or leave a comment below.

I was looking for the shortest tutorial on the basics of using Git from the command line. This one, Git Tutorial 4: Basic Commands: add, commit, push from YouTube was pretty good.

Here are some notes I made from watching that video:

  • The git status command will show you files and folders that have changes. It also shows you files that you've already committed into your local repository, but haven't pushed yet into a remote server.
  • The git add command adds files that have changes into a staging area on your local computer.
  • The git commit command will commit those changes into your local repository. Emphasis on local. At this point your changes are not saved to a remote server like Github just yet. The committed changes are still on your local Git repository.
  • The git push command is the one that will send your changes up to your remote Github repository.

This next tip is not something I learned from the video, but from someplace else that I don't remember.

  • To get out of a long results screen from using the git log command, you can type q.

Tags: #Git

Discuss... or leave a comment below.

Update 4/21/2021: I've decided to keep my software development posts separate from my personal posts. I've tried having them both on my journal and I didn't really like how they turned out. So, I've created this new dev blog on write.as to house my posts on software development.

I started this dev blog back in December 2018. It initially started out as a Jekyll Now blog hosted on Github Pages. After about two weeks I made the switch to a Wyam powered blog. And it's been that way since then.

This was my first real website. The first one that I bought a domain name for. Fast forward to 2021 and I now have 4 websites. There's this dev blog, my personal journal, my music blog and a photo-blog. At one point in 2020, I also had a micro-blog that has since been discontinued. So, in total, I had five websites.

After my second digital declutter, I've come to the realization that five websites is one too many. I felt like I couldn't keep maintaining all five at once. Since then, I've been thinking about reducing the number of websites I maintained.

I've thought about combining this dev blog with my personal journal a few times in the past. What was holding me back every time, was that I wasn't sure it was a good idea to have one site that contained both professional and personal content. However, I was also keenly aware of the creeping exhaustion of maintaining multiple websites at once.

There's also the fact that to publish content on this dev blog, I needed to do it on a machine that had .NET Core, Git and Visual Studio Code installed on it. On the other hand, to publish content on my personal journal, all I needed was a web browser.

So, in the interest of simplifying things for 2021, I've decided to stop publishing software development posts on this blog. I'm keeping the existing content on this blog for now. But new software development posts will now be published on my personal journal.

I'm not sure if there are a lot of people who read this dev blog. If you are one of them though, I would like to invite you to check out my personal journal. And if that's something you don't want to do, that's okay too. In any case, thank you for reading this post and I hope you have a nice day!

Tags: #SiteUpdates #Blog

Discuss... or leave a comment below.

When working with a Windows Forms TextBox, yes I was working with a Windows Forms TextBox 😀, and you want to display updates periodically while a long task is running, you can make use of the Application.DoEvents() method.

I think a better solution is to use a BackgroundWorker class for this. But, if you're working on an unimportant utility tool or a throwaway app, using Application.DoEvents() should be good enough.

Tags: #DotNet #WindowsForms

Discuss... or leave a comment below.

Most of the time, using display: none; is all you need to hide an HTML element. But every once in awhile, doing so will hide the element, but would not reclaim the space the element would have been occupying.

To hide an HTML element and not have it take up space, you can do something like this:

#post-signature-hidden {
    max-height: 0;
    margin-top: -3em;
    visibility: hidden;
}

In case you're wondering, that's the CSS I use to stop my Post Signatures from showing up on the pinned pages on my journal.

Tags: #HTML #CSS

Discuss... or leave a comment below.

Enter your email to subscribe to updates.