Git checkout command and switching commits, branches

The git checkout command in git can be used to switch to another branch, but also to an older commit on the same branch and back again. One of the major reasons to use source control to begin with is so that I can go back to any point in development to which a commit has been made. Another major feature of using git is branching, being able to create a whole other branch to make some changes that may or may not be merged down into the main master branch at some point.

The checkout command can then be used to switch the current head of the git folder to a given commit, it can also be used to switch back to the latest commit for a branch by just giving the branch name rather than a commit hash id. The git checkout command is then one of several commands that I or any developer that uses source control should be aware of. So it is worth it to write about a few simple examples of the git checkout command that have to do with typical use cases.

Read More

Word Count History nodejs example

This nodejs example is a project that I wanted to start a long time ago, but kept putting off. It is a script that will use a git log command to get a list of commit hash ids from the latest commit on master. Once it has a list of commit hash ids it will use a git checkout command to switch to the oldest commit in the list. From there is will loop up back to the newest commit in the list again.

The full idea that I had for this example is to have a script that will create a word count history for my blog post collection. It is just one little idea that I think might help me to stay the course when it comes to working on this blog posts and javaScript examples. In other words the general idea is to have a tool that will help me to track productivity by tracking how much writing I am doing every day, and having a script that will create word count totals per day or commit. However as of this writing I have not got this far with the script, and depending if I get some more time to work on it I might not finish.

Read More

The node exec child process method

The nodejs exec method of the nodejs built in child process module is one way to go about running an external command from a nodejs script written in javaScript. The other method of interest in the child process module would be the spawn method. Both the exec method and the spawn method work in a similar way with one significant difference and that is how the methods are called. With the exec method the command can be called with a single string, where the spawn method just the command is given as the first argument, and then any additional options much be given as elements in an array as the second argument.

Read More

Linux Aspell for spellcheck on the command line

The Linux Aspell command is a common spell check command that can be used to preform a spell check on some text. The text can be given to Aspell by way of a file name, or it can be piped in to the standard input of Aspell. The result is a list of stars for each word that is in the used word database for Aspell, or an ampersand for each word that is not in the dictionary followed by some spelling suggestions.

So this will be a quick post on how to go about using Aspell in a Linux environment where the command is available to preform a spelling check on some text.

Read More

On visibility change event

The on visibility change event of the document object in client side javaScript will fire each time the content of a web page will become visible or hidden. So in other words this event will fire each time the tab of a browser window will become visible or invisible as a user switches from one tab to another. So this is event can prove to be helpful when it comes to switching things up a little each time the user navigates away from a website of mine to another tab in a browser window of theirs. For example I can use less resources when it comes to rendering a view, and use any and all available resources just updating a state.

On top of the on visibility change event there is also the visibility state property of the document object that can be used as a way to probe for the status of the current tab and if it is active or not. Another document property that comes to mind is document title which is a way to set what the title text of a tab is as that would be the only way to inform the user of something if the tab is not active.

So if I am ever in a situation in which I need to define a little code that will change things each time a user switches tabs, the use of this kind of event is one way to go about doing it. When a tab is not active it is possible to keep doing things in the background, but often things will change and only so much can happen over a period of time. For example methods like setTimeout will get throttled down, and it will not be possibles to file a method over and over again at a speed faster than one call per second with such a method regardless of what time value I give.

In this post I might not cover every little detail about everything that will come up with this sort of thing, but I will be writing about at least a few things beyond just the on visibility change event itself.

Read More