Reasons Why You Should Keep Learning C/C++

I found this post interesting. C++ is hard and vast, but the payoff is immense.

How Not To Code

C

Many beginners and students find C/C++ language hard to master because it requires them to think a lot. There are many language-specific quirks, especially in C++, that give students and programmers a hard time. It also has a steep learning curve and is rarely used in modern application development, which prompts many people to give up learning C/C++. However, even with these challenges, it is important for students to continue learning this programming language. This article highlights reasons why one should keep learning C/C++.

View original post 444 more words

Advertisements

Leave a comment

Filed under Uncategorized

Using Your Browser From the Command Line

Howdy!

I know it’s been a while since I posted – being selfish with all the new things I’ve been learning. I’m sorry. Today I was reminded in strong terms that sharing and giving are crucial, and without all the good stuff other people are posting on the internet, I wouldn’t know most of what I know today.

I want to talk about starting your browser from the command line, in this case I’m using Firefox on Windows. The terminal I’m using is Powershell.

For a long time, I got into the habit of starting my browser like this:

start firefox

I can open my favourite social media site from the shell like this:

start firefox twitter.com

Note that I didn’t even have to prepend the URL with http(s):// or www! Neat, eh?

Sometimes, when I’m really being lazy and I quickly want to jump to Google and conduct a search on “firefox command line options” from there, I just type

start firefox www.google.com/search?q=firefox+command+line+options

I know that this example is rather contrived, but if you understand the basics of HTTP/HTTPS and query strings, this should be easy to grasp.

Having done this for a while, today I decided to look at the Mozilla Developer Network (MDN) reference to see what Firefox had to offer by way of command line options.

And BOOM I hit a mother lode! So far I have only skimmed over it, but I’m astounded at the possibilities I see – this should really make for good browser automation. I wonder why I never thought of it before now.

If I find anything really useful I promise to share (this time). If you’re interested, have a look at MDN’s Firefox Command Line Options page.

I’m out!

1 Comment

Filed under Computers & Internet

Quick Tip on Deleting Directories in R

When trying to delete a directory, one can encounter some unexpected problems. The function for carrying out this operation is unlink, which accepts the director name as its first argument; other arguments are recursive (a logical vector or length 1 indicating whether we want to delete subdirectories, and force, also logical, which tries to override file permissions in most cases. It returns 0 when successful and 1 when not.

But there is a gotcha to using the function. First let’s list the contents of the HOME directory

> list.files()
 [1] "3D Objects"
 [2] "AppData"
 [3] "Contacts"
 [4] "Desktop"
 [5] "Documents"
 [6] "Downloads"
 [7] "Favorites"
 [8] "IntelGraphicsProfiles"
 [9] "Links"
[10] "MicrosoftEdgeBackups"
[11] "Music"
[12] "New folder"
[13] "NTUSER.DAT"
[14] "ntuser.dat.LOG1"
[15] "ntuser.dat.LOG2"
[16] "NTUSER.DAT{a70b1724-6bc8-11e8-a408-d0bf9c58c5d2}.TM.blf"
[17] "NTUSER.DAT{a70b1724-6bc8-11e8-a408-d0bf9c58c5d2}.TMContainer00000000000000000001.regtrans-ms"
[18] "NTUSER.DAT{a70b1724-6bc8-11e8-a408-d0bf9c58c5d2}.TMContainer00000000000000000002.regtrans-ms"
[19] "ntuser.ini"
[20] "OneDrive"
[21] "Pictures"
[22] "R"
[23] "Saved Games"
[24] "Searches"
[25] "source"
[26] "Videos"

Let’s say we want to delete the ‘New folder’ directory

> (unlink('New folder/', recursive = TRUE, force = TRUE))
[1]

It fails!

Even when you study the help file, the source of this failure is not apparent.

Well, it turns out that the function does not recognize the trailing slash that indicates that we are dealing with a directory. This is always added when you use tab completion for the directory name.

So, when we type

# Remove trailing slash in directory name
> (unlink('New folder', recursive = TRUE, force = TRUE))
[0]

The function succeeds, as evidenced by listing the directory contents

> dir()
[1] "3D Objects"
[2] "AppData"
[3] "Contacts"
[4] "Desktop"
[5] "Documents"
[6] "Downloads"
[7] "Favorites"
[8] "IntelGraphicsProfiles"
[9] "Links"
[10] "MicrosoftEdgeBackups"
[11] "Music"
[12] "NTUSER.DAT"
[13] "ntuser.dat.LOG1"
[14] "ntuser.dat.LOG2"
[15] "NTUSER.DAT{a70b1724-6bc8-11e8-a408-d0bf9c58c5d2}.TM.blf"
[16] "NTUSER.DAT{a70b1724-6bc8-11e8-a408-d0bf9c58c5d2}.TMContainer00000000000000000001.regtrans-ms"
[17] "NTUSER.DAT{a70b1724-6bc8-11e8-a408-d0bf9c58c5d2}.TMContainer00000000000000000002.regtrans-ms"
[18] "ntuser.ini"
[19] "OneDrive"
[20] "Pictures"
[21] "R"
[22] "Saved Games"
[23] "Searches"
[24] "source"
[25] "Videos"

Watch out for this!

Leave a comment

Filed under Computers & Internet

Environments and how to apply them

Adventures with R

I’ve been learning a lot these days. It’s been coming fast and heavy and I have not been able to document much of it. One of the areas I kind of focused on was Environments. I’ve glanced at (but not finished) the chapter Hadley Wickham wrote in his book ‘Advanced R’. One thing that stood out clearly was that environments are data structures just like any other in the language. I will pause there for now.

What I rushed out to post is something I just saw in a post in R Bloggers. The main gist was about loading .RData files safely and this is one area where environments can be put to good use.

Rather than loading the objects from that file into the Workspace (or global environment), just create a new environment with new.env() and load the saved objects into into it by passing it as…

View original post 86 more words

Leave a comment

Filed under Computers & Internet

What a “freak” occurrence taught me about installing R packages

Adventures with R

I was trying to set up a particular Rmarkdown document in such a way that other users on our team, who might not have all the necessary packages installed, could get them automatically.

The first time I tried it out it worked perfectly, but later when I re-knitted the document, this funny window popped up

R package list

I was quite surprised! Oh, what had I done now?

To cut the story short, the answer lies in the R documentation via help('install.packages'):

part documentation for R function

So, argument pkgs (3rd paragraph), when zero-length, is what produced the popup. After installing the missing packages in the first pass of the code I wrote, the vector not_installed was subsequently zero-length. As an example, when one does this…

…our listbox appears.

I therefore decided to throw in a conditional statement to skip the installation step in the event that all required packages are already present:

Done.

View original post

Leave a comment

Filed under Uncategorized