lodash constant and functions that return values

The lodash constant method is a method that will create a function that will return a given static constant value each time it is called. On the surface lodash constant might seem pointless, but there are some situations in which I might actually want a method like this. Say for example I have a function that expects a function as one of its arguments, I can not just pass a static value to it, so instead I would need to pass a function that will return that static value.

There are a number of built in methods that will return a static value each time it is called to begin with in lodash, but the lodash constant method is the built in way to create my one such methods. It is also true that it is not so hard to just do the same things without the use of lodash, so I will be looking at some plain old vanilla javaScirpt alternatives to using the lodash constant method also here.

Read More

Creating arguments from standard input with the Linux xargs command

So you have some standard output from one command, and you want to use that standard output to create values for arguments to another command rather than pipe it to the standard input of that command. In other words the standard input of many commands might expect content or some other kind of data stream from the standard input, not arguments. Take for example the Linux cat command, file names can be given via arguments, but not by way of the standard input, with cat the standard input is used as an alternative to opening files and works in a similar way to that of echo when used that way.

Still there must be a way to go about piping the output of one command as data that is to be used for one or more arguments in another command, rather than data to be sent to the standard input of this other command. One command that can be used to do so is the Linux xargs command that should be there to work with on most Linux systems. In this post I will be covering all the basic examples that come to mind when using this kind of command such as using data from a command for just one argument, as well as more than one.

Read More

Linux find command

The Linux curl command is a way to download a file from a given URL, but it is also a bit more than just that. It can also be used to make various kinds of http requests from the command line such a POST requests, and can also be used as an FTP client, along with many other various use cases.
So the curl command is a helpful little command to be aware of when it comes to getting data from a public URL, or anything to that effect outside of a web browser. So in this post I will be going over just a few quick, simple use case examples of the Linux curl command just for the sake of getting started with it.

Read More

Linux find command

The Linux find command can be used to find one or more files from a starting point in a file system. The starting point can be the current working directory for example, or any other path that one has permission to access for that matter. The command will loop over all folders recursively until it is done searching for files, and will output the paths to files that it finds in the standard output that match the given search pattern to look for.

On thing to point out is that the Linux find command should not be confused with the grep command although the two commands are a little similar. Where the Linux grep command is used to look for patterns in content, the Linux find command is used to look for patterns in file names. So the command can be used by itself if I just want to find one or more files that fit a given pattern, or with grep via piping to find files and on top of that look farther into the content of each file.

So in this post I will be looking at a few examples of how to get going with the Linux find command.

Read More

The File Protocol and getting started with javaScript

I have wrote a post on getting started with javaScript in general, and another getting started post that is centered on getting started with the javaScript console rather than other ways to get going with javaScript. However I have not yet wrote a post on getting started with javaScript, and using the file protocol of a web browser to run files that are stored locally on the personal computer that you are using. This is strange sense that is how I first started way back in the day for me at least so this is something that I should have go to in my writing a long time ago actually. Anyway better late then never so I thought I would take a moment to write a post on getting started with javaScript, and using the file protocol, a text editor, and a web browser as a starting point to learn javaScript.

If you do not know what the file protocol is it is a way to load an html document, or other assets into a web browser that is stored locally on your computer. In other worlds loading a file in a web browser by way of file:\/\/ rather than https:\/\/. This might not be the best way to go about doing things as in some situations you will run into problems that have to do with the use of the file protocol, but it can still be thought of as a stepping stone to using https that will result those problems.

One nice thing about the file protocol is that you do not have to take the time to fool around with some kind of http sever to serve static assets that you will be starting out with. You can just create a plain old html file with some javaScript, save the file locally, open it up in the browser and your are done. So I would say that it is a good starting point, and as long as one avoids things that will cause problems it will work okay as a starting point when it comes to learning javaScript for the first time.

Read More