It is possible to program the ATMega328p microcontroller found on the Arduino UNO using the AVR C Library written specifically for Atmel hardware. The benefits of using the AVR C Library are flexibility and a smaller firmware binary. You can checkout how the AVR C Library is used in this Github repository. There is also code written as a "rolled-out" version of the AVR library code which will reveal how to initialize and interact with registers on the MCU. Enjoy.
I always thought that copying and moving files in the terminal had the same end result: the file in the new location would be exactly the same as it was in the old location. Well, that is not the case. Here is the story of how I found out.
After moving image files (using mv) from my non-root home directory to the /var/www/html directory and changing the files' user and group ownership and access modes to the appropriate values for public availability, HTTP requests for the image files would yield a 403 error. This led to a few hours of changing server configuration files and trying different image types and sizes. Nothing worked. Then I decided to inspect the image files using a the GNU stat command. There was one image file in my server's root directory that could be requested without receiving a 403 forbidden error; so I used the stat command on that file and on one of the files that was not publicly visible. It turns out the "context" of the files was different. See the images below.
Now, if an image file is copied (using cp) from the non-root directory to the /var/www/html directory, the context of the file will change to the appropriate one. The context also changes when the file moved into the html directory is copied into the html directory itself. So what is this file "context?" It is an implementation of SELinux, and it is referred to as the security context string. For more information, see Fedora Wiki: Security Context. And besides the stat command, the security context string can also be viewed using ls -Z <filename>.
Another thing I should mention is that when the cp command is used as root user (i.e. by prefixing cp with sudu), I did not have to change the files' user and group ownership nor access modes. The copy command is thus more convenient than the move command, although the original file still needs to be deleted if only the copy is desired.
Consider the following assignment statement:
auto initList = { std::make_pair(*std::make_unique<TestClass>(), 0), std::make_pair(*std::make_unique<TestClass>(), 1) };At compile time, the expression on the right-hand side of the statement evaluates to
std::initializer_list<std::pair<TestClass, int>>If the initializer_list needs to be passed to a std::map initializer-list constructor, the compiler will throw an error because std::map uses as the default allocator an std::pair with the first template parameter as a constant data type. Thus, upon declaration, it is required that the template parameter of the std::initializer_list be of type std::pair with the first template parameter as a constant and not mutable type. The compiler's static type checking system "has no common sense," as Stroustrup said himself in A Tour of C++ (2nd edition).
To prevent the type system from throwing an error when a std::map object is declared with an initializer_list, the initializer_list needs to be declared explicitly. The following code is valid at compile time:
std::initializer_list<std::pair<const TestClass, int>> initList = { std::make_pair(*std::make_unique<TestClass>(), 0), std::make_pair(*std::make_unique<TestClass>(), 1) }; std::map<TestClass, int> map2{initList};The assignment operator above next to initList can be removed since the declaration type was specified; plus this is C++ and not C. Bjarne Stroustrup strongly recommends doing this on page 159 of his book The C++ Programming Language (4th edition).
Thinking about encrypting some plaintext? How about creating a rigged card shuffler for your casino-owning client? Check out this project cipher-stream-applications for ideas on how to implement such applications. Readme coming soon.
When I used calloc to copy a character array that contained 24 elements of characters and no termination character to another pointer to characters, the length of the copy calculated using strlen was 27 elements. The calloc documentation at cppreference.com says that "number of allocated bytes is not necessarily equal to num*size" because of different alignment requirements. I am not sure if this issue will always occur when a character array of 24 elements is copied to another memory location. It would be nice to test this out in other programs run on the same computer as well as other computers with a different architecture. The issue also occurred when attempting to copy an array of 40 elements which resulted in 43 bytes of memory being allocated to the copy. After observing the first occurrence, intuition led me to believe that "over-allocation" would occur every 24 bytes, but it seems like it may occur randomly. I'll investigate this another day. For now I'll stick with malloc. Wait.. malloc has the same effect... This goes deeper than I thought. Expect an article about this behavior to be posted on this website in the near future.
Want to know how to quickly get a webserver running? Check out my article How to Setup a Webserver. Here I will list out the order of steps you need to take from purchasing a (minimum of $5) virtual server from the server-hosting company DigitalOcean to getting a simple HTTP server running. All, if not most, of the commands that need to be executed can be found in this article. Knowledge of working with DigitalOcean, or any other cloud-hosting provider, is required to get through this process.
Hi there! This is the website owner coming in as KO4KUY (my FCC call sign). After a period of writing up documents for my personal projects and other endeavors such as university courses, I have decided to make a website where I can share info about my work and interests. You can reach out to me via email if you would like to get in touch. Enjoy!