<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Damon Nyhan on Medium]]></title>
        <description><![CDATA[Stories by Damon Nyhan on Medium]]></description>
        <link>https://medium.com/@anovacap?source=rss-f9c037323958------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Y62wk_5BKadCiDQ1qVMAfg.jpeg</url>
            <title>Stories by Damon Nyhan on Medium</title>
            <link>https://medium.com/@anovacap?source=rss-f9c037323958------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 12:42:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anovacap/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[https://www.holbertonschool.com-Enter-Now what?]]></title>
            <link>https://medium.com/@anovacap/https-www-holbertonschool-com-enter-now-what-c14727934073?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/c14727934073</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[web-hosting]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Sun, 20 Jan 2019 20:11:48 GMT</pubDate>
            <atom:updated>2019-01-20T20:11:48.958Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*Ebz1_Z5XMFCHuORQ.png" /><figcaption>Ohh No! Attacker.</figcaption></figure><p>This post is a brief explanation of what happens after <a href="https://www.holbertonschool.com/">https://www.holbertonschool.com</a> is typed into a browser and sent.</p><p><a href="https://www.holbertonschool.com/">https:holbertonschool.com</a>, (//www. is a subdomain and is not necessary in this case,) is whats known as a <a href="https://en.wikipedia.org/wiki/URL"><em>Uniform Resource Locator </em>(url)</a>. The url starts with <em>Hypertext Transfer Protocol Secure</em> (https) and ends with the <em>Domain Name</em> holbertonschool.com. HTTPS is the the secure version of the standard web transfer protocol (HTTP), adding a layer of security to the data in transit through a <em>Secure Socket Layer</em> (SSL) or <em>Transport Layer Security</em> (TLS) protocol connection. The address is translated to <a href="https://en.wikipedia.org/wiki/Internet_protocol_suite"><em>Transmission Control Protocol/Internet Protocol</em> (TCP/IP)</a>, which is the language a computer uses to access the internet. A <em>Domain Name System</em> (DNS) query is a demand for information sent from a browser (DNS client) to a DNS server where the <em>Domain Name</em> is <strong>looked up</strong> and converted to the <a href="https://en.wikipedia.org/wiki/Internet_Protocol"><em>Internet Protocol address </em>(IP)</a>.</p><p>The <a href="https://www.holbertonschool.com/">https:holbertonschool.com</a> query is now converted to a proper address and encrypted so hackers can’t understand the information they have intercepted. It then reaches the Holberton School load balancer which is set up to handle incoming requests from users for information and other services. Once a request is received, the load balancer first determines which server in a pool is available and online and then routes the request to that server. During times of heavy loads, the load balancer can dynamically add servers in response to spikes in traffic and it can drop servers if demand is low.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/0*3D6mb0BZ17wYM6M3" /></figure><p>Between the load balancer and the web server sits the <a href="https://en.wikipedia.org/wiki/Firewall_(computing)"><em>firewall</em></a>. A working definition of firewall is a device that selectively prevents traffic forwarding to the web servers. Software firewalls use filter algorithms to ensure that bidirectional flows are matched to approved connections. The firewall tracks all the IP packets in both directions and ensures that only packets from a valid session are passed through.</p><p>Once passed the firewall, your query has arrived at the Holberton School web server. The web server presents the static html file, returning the queried page, or a 404 response if the file is not found. An <a href="https://en.wikipedia.org/wiki/Application_server"><em>Application Server</em></a> is used to handle complex, large applications otherwise know as an <a href="https://en.wikipedia.org/wiki/Application_programming_interface"><em>Application Program Interface</em></a><em> </em>(API). It can have backend logic and makes the application dynamic and interactive with the <a href="https://en.wikipedia.org/wiki/Database_server"><em>Database Servers</em></a>. The Database Server houses all the data, organizing it for retrieval or collection which is handled by the application server.</p><p>In conclusion, this post covers the TCP/IP conversion, DNS look up, the Load Balancer and Firewall combination, the Web Server, the Application Server and the Database Server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c14727934073" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recursion In The Stack — A Simple Diagram.]]></title>
            <link>https://medium.com/@anovacap/recursion-in-the-stack-a-simple-diagram-eb5907287eab?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb5907287eab</guid>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[recursion]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Mon, 17 Dec 2018 04:37:22 GMT</pubDate>
            <atom:updated>2018-12-17T19:03:08.677Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Recursion In The Stack — A Simple Diagram.</strong></h3><p>Here is the recursive function.</p><pre>int _pow_recursion(int x, int y)<br>{<br>    if (y &lt; 0)<br>    {<br>        return (-1);<br>    }<br>    if (y == 0)<br>    {<br>        return (1);<br>    }<br>    return (_pow_recursion(x, y - 1) * x);<br>}</pre><p>The following steps explain how the function executes. First, the ‘y’ variable is checked if it is less than 0, returning -1 if it is. Second, y is checked if it is equal to 0, returning 1 if it is. Last, the _pow_recursion function is called in the return statement where ‘y’ is decremented by 1 and the value the function returns is multiplied by ‘x’. When ‘y’ is equal to 0 the if statement ‘if (y == 0) returns 1, ending the recursion. The bottom return statement is not executed because of the return above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*R71Nuw5PRWbkB9DDcuFjFg.png" /><figcaption>_pow_recursion(3, 3) returns 27 to main.</figcaption></figure><p>Recursion is a great programming tool to understand but rarely practical to use. Recursive functions do not help a program run faster or save save memory. A recursive function that calls and stacks in memory in an infinite loop will result in a <a href="https://stackoverflow.com/questions/3021/what-is-recursion-and-when-should-i-use-it">stack overflow</a> error as the space in memory is used up. The best reason to use recursion is to make the code easier to read, cutting down on the number of lines of code used versus a for or while loop but the reader must truly understand how it works under the hood.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb5907287eab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everything that can be automated will be automated — IoT….]]></title>
            <link>https://medium.com/@anovacap/everything-that-can-be-automated-will-be-automated-iot-d991fe135887?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/d991fe135887</guid>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Wed, 21 Nov 2018 18:17:27 GMT</pubDate>
            <atom:updated>2018-11-21T18:17:27.914Z</atom:updated>
            <content:encoded><![CDATA[<h3>Everything that can be automated will be automated — IoT….</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*IxUBctlZQnoLuECh.jpg" /><figcaption>An <em>embedded system</em> on a plug-in card with processor, memory, power supply, and external interfaces</figcaption></figure><p>The <a href="https://en.wikipedia.org/wiki/Internet_of_things"><strong>Internet of Things</strong></a> or IoT, is all about embedded systems interconnecting. An <a href="https://en.wikipedia.org/wiki/Embedded_system"><strong>embedded system</strong></a> is a combination of computer software and hardware with a dedicated function that is either fixed or programable within a larger mechanical or electrical system, often with real time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. Embedded systems control many devices in common use today. Ninety-eight percent of all <a href="https://en.wikipedia.org/wiki/Microprocessor"><strong>microprocessors</strong></a> that are manufactured components of embedded systems. A great example of an embedded system that people living in cities come across everyday is the new smart connected parking meters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/188/1*J4vmFa2yA4b1EjAiHrLC0A.jpeg" /><figcaption>Smart Connected Parking Meter</figcaption></figure><p>The smart connected meters have a sensor, that tracks the parking space availability, which then connects to a management system via a secure wireless connection. The management system then connects to the consumer on an app via the internet. Drivers find parking spaces quicker, payment is easier, including extension of parking time, and useful data is collected for analysis.</p><p>Interconnecting embedded systems bring together two evolving technologies: wireless connectivity and smart sensors. Combined with recent advances in low power <a href="https://en.wikipedia.org/wiki/Microcontroller"><strong>microcontrollers</strong></a> , these new “things” are being connected to the internet easily and inexpensively, bringing in a second industrial revolution. These connected embedded systems are small microcontroller based computers that do not require a human interface. Instead of interacting with a human these systems use sensors or other advanced detection mechanisms to collect data that has value and is part of a larger system. This data is then networked as part of a larger system. While the term “Internet of Things” implies that these sensors are networked via the world wide internet using WiFi or Ethernet, the networking can also be performed using protocol such as <a href="https://en.wikipedia.org/wiki/Zigbee"><strong>ZigBee</strong></a> or<strong> </strong><a href="https://en.wikipedia.org/wiki/Bluetooth"><strong>Bluetooth</strong></a> that does not have an IP address. The networking protocol is selected based on the distribution of <a href="https://en.wikipedia.org/wiki/Node_(networking)"><strong>nodes</strong></a> and the amount of data to be collected. This data is sent over the network to the main hub or computer. This main computer collects and analyzes the data, storing it in memory and even making system decisions based on the results of the analysis. In the case of the smart connected parking meter, the data is made available to the consumer via an app connected to their service providers cellular data network.</p><p>Typically the Internet of Things is about high integration in low power systems. Since the value of the data collected must be worth the current draw of the system, the choice of microcontroller is important not just for the processing power but also for the level of on-chip integration. As the level of integration has increased for microcontrollers, the power consumption has dropped, helping to enable the Internet of Things at just the right time. Although an 8-bit microcontroller may be useful for simple, low data low bandwidth nodes, the majority of IoT applications with use either 16-bit or 32-bit microcontrollers. 16-bits are used for basic nodes of low to medium complexity where the data is not part of a realtime system. The advantage of 16 bits is that it can be the best compromise of low power and data throughput. However, the most common data bus for an IoT node is 32-bits where performance is essential and a high level of integration is required. Some 32-bit microcontrollers even have sensor interfaces and on-chip RF radios, perfect for IoT nodes.</p><p>The most important criteria used when selecting the type of connectivity for an IoT node is that the value of the data collected must be worth the current draw, and often the biggest current draw in an IoT node is the radio. In other words, it’s not necessary to use a 43 MSPS (Mega Samples Per Second) wireless connection if the system only needs to transmit 32 bytes of sensor data every five minutes. A voltage regulator is usually either on the board or integrated into the microcontroller to supply regulated current to the system. More sophisticated nodes with high frequency processors may have a power management chip, while low power battery-powered nodes may require a DC/DC converter or a battery management chip to supervise rechargeable batteries.</p><p>The following are just some of the protocols available for networking distributed embedded systems along with their power use attributes:</p><ul><li>WiFi: Draws the most power. Used for high data rate, high amounts of data. Useful for streaming applications such as security cameras, as well as systems where WiFi is already used and so can be easily connected.</li><li>Bluetooth: useful for low power, short distance networks.</li><li>802.15.4: Used for low data rate, battery powered networks distributed over a wide area. Supports <a href="https://en.wikipedia.org/wiki/Star_network"><strong>star networks</strong></a>, as well as <a href="https://en.wikipedia.org/wiki/Peer-to-peer"><strong>peer-to-peer networking</strong></a> where each node can act as a repeater, retransmitting data received from other nodes thereby extending the range of the system.</li></ul><p>Data is collected in an IoT node from different sensors. The type and accuracy of the sensor is dependent upon the value of the data being collected and the amount of data to be processed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*WHQrKg4SkFLs0WDN.png" /><figcaption>IoT Sensor Node Diagram</figcaption></figure><p>Many IoT systems have some type of environmental sensors to measure motion, position, acceleration, pressure, temperature, humidity, etc or they may have an optical sensors that can detect the presence of light in different wavelengths, including infrared. The IoT systems could also have video camera sensors, including <a href="https://en.wikipedia.org/wiki/Image_sensor"><strong>CCD and CMOS</strong></a> light sensors, that are used where video monitoring is required such as automated highway traffic management systems. Some systems being monitored may already provide a signal and that can be fed to an <a href="https://en.wikipedia.org/wiki/Analog-to-digital_converter"><strong>analog to digital converter</strong></a> or an analog front end. Smart Sensors are sensors that have some data processing on board. These can be anywhere from environmental sensors that perform basic processing of the data to high accuracy <a href="https://en.wikipedia.org/wiki/Microelectromechanical_systems"><strong>MEMS</strong></a> sensors with a gyroscope and accelerometer with integrated digital processing for sensor fusion calculations.</p><p>All the data collected needs to be stored somewhere. Many simple IoT nodes will use the memory available on the microcontroller, but more complex nodes may require additional Flash memory, either mounted on the circuit board or by a memory module inserted into an expansion slot. More sophisticated systems that might be found in a factory can require significant resources and can have additional <a href="https://en.wikipedia.org/wiki/Random-access_memory"><strong>RAM</strong></a> on the board. And last, there is The Cloud where the data can be uploaded, stored, and even processed then fed back to the IoT system. While many IoT nodes can use the Flash memory on the node’s microcontroller, some systems require additional memory for either the system program or for data storage. These systems can utilize <a href="https://en.wikipedia.org/wiki/Flash_memory"><strong>Flash memory</strong></a><strong> </strong>on the <a href="https://en.wikipedia.org/wiki/Printed_circuit_board"><strong>PC board</strong></a> (PCB). Although many IoT nodes will have enough RAM on the microcontroller to perform its work, some very high performance systems may require additional RAM memory. This may be for normal program storage, or for very high performance digital processing nodes the RAM may be loaded with the program memory on boot, enabling the system to run code out of RAM much faster than from Flash by reducing the wait states for the processor. Some IoT nodes may require the use of removable memory for expansion, security, or program memory storage. Most IoT systems will transfer data to Cloud storage from the main host system. However, some IoT nodes may directly upload to cloud storage, or even get its code from cloud storage.</p><p>The FBI warns that I0T devices are very attractive targets for hackers. Hackers can typically attack them simply by exploiting weak authentication or unpatched firmware, or even just from taking advantage of default usernames and passwords. Because of this, security is the most important concern for IoT nodes. Most 32-bit processors introduced today now have some form of encryption, the most common being <a href="https://en.wikipedia.org/wiki/Advanced_Encryption_Standard"><strong>AES256</strong></a>. The increased security helps the processor perform a secure boot, insuring that the core is running the software that it is supposed to run. Encryption security is also used to encrypt the data that is transmitted over the network, insuring that it is viewed only by those systems authorized to receive the data. Beyond the encryption security, it is the responsibility of IoT device owners to reboot their devices, change passwords, update firmware, check their firewalls, and isolate IoT devices. Since most IoT device owners aren’t even aware of the security risk their IoT devices are subject to, it is unlikely that they will be responsible enough to keep them secure. Compromised IoT devices in their great numbers can serve as proxies for masking illicit internet activity, secretly probing legitimate sites, or actively attacking sites in huge botnet swarms.</p><p>There is so much room for growth in the IoT industry. In 2017, Forbes estimated the global IoT market will grow from $157 billion in 2016 to $457 billion in 2020. That would be a compound annual growth rate of 28.5%. With growth numbers like these, the IoT industry is set to lead the way to the next industrial revolution as everything that can be automated will be automated.</p><p>References:</p><ul><li><a href="https://enterpriseiotinsights.com/20180901/fundamentals/sensor-applications-smart-parking">Sensor applications in smart parking</a></li><li><a href="https://en.wikipedia.org/wiki/Internet_of_things">Internet of things - Wikipedia</a></li></ul><p><a href="https://www.wired.co.uk/article/internet-of-things-what-is-explained-iot">https://www.wired.co.uk/article/internet-of-things-what-is-explained-iot</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d991fe135887" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python: Mutable and Immutable Objects]]></title>
            <link>https://medium.com/@anovacap/python-mutable-and-immutable-objects-b158ef554eb7?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/b158ef554eb7</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Wed, 10 Oct 2018 05:03:01 GMT</pubDate>
            <atom:updated>2018-10-10T05:03:01.259Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fz288Hx8N2SgkzgOgpyviA.jpeg" /></figure><p><strong>A Python object</strong> is either mutable, meaning capable of being changed after it is created or immutable, unchangeable after creation. Since Python is an Object Oriented Programming language, It is important to understand which object types can truly be changed or are just faux changed. To help understand what an object is and if it truly can change, I will use the Python builtin functions type() and id() as well as the comparison operators ‘is’ and ‘==’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/168/1*i_JQsz6Ed3i3Roqp3T20mw.png" /><figcaption>type()</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/172/1*daQ4vNiPB_cq2-UEwTgfSw.png" /><figcaption>id()</figcaption></figure><p><strong>Built-in</strong> type() , when called on a variable, returns the object type the variable points too. Built-in id(), when called on a variable, returns an integer which is guaranteed to be unique and constant for this object during its lifetime. The operator ‘is’ is a boolean evaluator that returns True if object a and b have the same id. The ‘==’ operator returns True if object a and b are the same thing but not necessarily the same id number.</p><p>The following are some <strong>mutable</strong> Python objects — list, dict, set, bytearray, and user-defined classes unless they are specifically made immutable.</p><p>The following are some <strong>immutable</strong> Python objects — string, tuple, int, float, bool and bytes.</p><p>Mutable objects like lists, as stated earlier, are able to be changed after they are created. Creating a list is as simple as making a variable name and binding it to a list object. If I assign y to x, y will have the same id as x. I can change x by appending 4 to it and y will be affected, showing that they are the same object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*47Ap6qajec_J60uRNwsaqg.png" /></figure><p>After appending 4 to x both x and y have the same id as they had before the append. This shows that the list was changed in place, retaining it’s id.If I use the list method ‘del’ to delete x, y is un affected and it’s object is safe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*xhd92Zi3VFH0LidLEqwmog.png" /></figure><p>If I add 3 to list x, y is no longer the same as x as seen above. The last example shows that list x and y can be the same but have different id’s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*i0M0ns-tcIIeRc61NIZT6Q.png" /></figure><p>The fact that x and y have different id’s even though they are the same is important to show how Python mutable objects act differently than immutable objects. Below shows how Python handles immutable objects like ints in contrast to mutable lists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*NFUFsYVKSZbsGHhdNndd2Q.png" /></figure><p>X and y have the same id even though they were created independently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*4ePMGoKnyEFYm2hz7XYCig.png" /></figure><p>The example above shows that unlike lists, when the variable copy z of x is created and later 1 is added to z, x stays 1 and z is updated. The important thing to understand is that immutable objects are quicker to access than mutable objects but changing them requires creating a copy, using more memory.</p><p>How are mutable and immutable objects handled in functions?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*tr3-pv-P-bDoct7L2PrhdA.png" /></figure><p>The picture above shows that the immutable int x is unchanged by the function add1. X remains 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*BDx1OMVfnZNaE1KDQSLQxw.png" /></figure><p>The above picture show how a mutable list is changed by the function addl. It changes from [1, 2] to [1, 2, 3] but the id of the list object is the same after the function as it was before.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b158ef554eb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Libraries vs Static Libraries]]></title>
            <link>https://medium.com/@anovacap/dynamic-libraries-vs-static-libraries-7eba71e999?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/7eba71e999</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Tue, 18 Sep 2018 04:56:47 GMT</pubDate>
            <atom:updated>2018-09-18T04:56:47.964Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Vd7NvQiN_Cy2og_AhMgrw.png" /><figcaption>All file.c to file.o to liball.so — shell script.</figcaption></figure><p>For the sake of simplicity, libraries are understood as a collection of functions available to the users of programming languages. All programming languages have libraries of common useful functions that are accessed by including them in the program file. In the C programming language add #include &lt;lib.h&gt; (lib.h, being a fictional library,) where as in Python add -import library or -from library import function.</p><p>If you are not familiar with low-level programming languages, you might not be aware that there are two types of libraries a writer of functions can create to house your functions. The first and least efficient library is called the Static Library. When a function from a static library is used in a low-level programming language the compiler changes the C code to Object code. The Object code of the function is included with the programs object code in the linker stage of compilation. Each Static library function used will be added to the Object code in the linker stage which then is add to the Executable file created to run the program. This process makes the compiling process slower and creates a larger executable file than if you were to use a function from a Dynamic library.</p><p>Creating a bigger executable file is just one disadvantage Static Libraries. Another disadvantage is if changes need to be made to the library, the changes will not be available to the users of the executable file that depends of the static library. The only real advantage in using static libraries is the application is guaranteed to work because the functions and library are maintained in the Executable. Windows OS users of long ago should remember when their system would take an update, updating libraries, and suddenly programs that ran flawlessly before the update were rendered useless until changes were made to the program to accommodate the changes the system update made to the Dynamic Libraries. The larger Executable file has everything the program needs to run.</p><p>Dynamic Libraries are contained in a file separate from the executable and are loaded by the operating system when the executable is run. This process is known as Dynamic linking. The operating system loads the shared libraries into a running process and then binds the libraries dynamically to the running process.</p><p>The creation of Dynamic Library is handled by a compiler such ass the GNU Compiler Collection, better known as GCC. First collect all your functions into one directory and run the following command to turn the C files to O files or Object files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_M60b3cXId1qLuugq30rWw.png" /><figcaption>Directory containing functions ready to compile to object code.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*tot8osmdUPjhD8z-LRCdVQ.png" /><figcaption>Command that makes object code from all (*) .c files.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QUHSXw7_WGMBg4WY7Sa30g.png" /><figcaption>Object files created (.o).</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Ftdo9KXLP64O6tZRAbx_tw.png" /><figcaption>Command to create Dynamic Library called libholberton.so from all .o files (*.o).</figcaption></figure><p>The Linux command “nm” with the -D flag to lists the Dynamic symbol values and symbol type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*A4Ljzf2sGwSvIl0IQMzULQ.png" /><figcaption>Linux command nm -D.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*NjtpkKoW1XldUUpvPCYIPw.png" /><figcaption>Linux command nm -D output.</figcaption></figure><p>The Linux command “ldd” followed by and Executable prints the shared libraries required by the Executable on the command line.</p><p>The Linux command “ldconfig”, creates the links and cache to the recent shared libraries found in the directory specified on the command line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UVDnWQOVRYgkby-F9WccJQ.png" /><figcaption>Linux command ldconfig performed on liberholberton.so (shared object.)</figcaption></figure><p>To temporarily change to a different library for an Executable to use, the Linux command “export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH” tells the os where libraries should be first searched, before the standard set of directories. Your Dynamic Library is now ready for use by the Executable.</p><p>Enjoy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7eba71e999" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You typed ls -l in Shell. What happens next?]]></title>
            <link>https://medium.com/@anovacap/you-typed-ls-l-in-shell-what-happens-next-b0ea8cc682e7?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0ea8cc682e7</guid>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Tue, 28 Aug 2018 23:16:20 GMT</pubDate>
            <atom:updated>2018-08-28T23:16:20.742Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*gpjHV6dCIMSz3D1il8-k9Q.jpeg" /></figure><p>In Unix and Unix -like operating systems, <em>ls</em> is a command to list the files in the current directory. If you add <em>-l</em> (flag) the files are listed in the <em>long </em>format, displaying Unix file types, permissions, number of hard links, owner, group, size, last-modified date and filename. The example below shows the files listed in a directory called bin that is located in the root directory. The permissions part can be broken down to 4 parts. First part in this example is “-” which specifies that this is a regular file. Other common uses are:</p><ul><li><em>d</em> stands for directory</li><li><em>l</em> this specifies symbolic links</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*Zdb7SkmYREq8dZCyPT1_Iw.png" /></figure><p>Next three parts are also called octets and they define a permissions applied to this file. First octet ( -rw- ) defines a permission for a file owner. In this case owner has read and write permissions. Second part ( rw- ) defines read and write permissions defined for a group. And the last part defines read-only permissions for others ( everyone else ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QgqewMej3IxrZdqGFGDCQg.png" /></figure><p>After ls is entered, the keyboard driver realizes that characters have been entered and pushes them to the shell via the standard input (<em>stdin</em>).</p><p>The string is passed as one single string . This is then split into tokens by excluding the white spaces. Our command has now two tokens, ‘<em>ls</em>’ and ‘<em>l’</em>. This is placed in an array of strings. This whole process is known as Tokenization, using<em> strtok() </em>found in the<em> string.h </em>header.</p><p>Now that the array is tokenized, we need to see if each token has an alias assigned. If an alias is found it is stored as a token after removing the spaces like before and again it is checked for aliases. Normally, an alias is stored in the following files:<em>~/.bashrc, ~/.bash_profile, /etc/bashrc, /etc/profile</em>.</p><p>Next, the computer checks if tokens are built-in functions or not. If the command is a built in, the shell runs the command directly, without using another program. For example, ‘<em>cd</em>’ is a built in; however, ‘<em>ls</em>’ is not a built in , so now system needs to find the executable or program for ‘<em>ls</em>’.</p><p>Interpreting and finding the executable for the command<em> </em>: After that, the bash interprets the command. The first search for the command ‘<em>ls</em>’ is done through $PATH. $PATH is an environmental variable which holds the paths of all executable programs. The search calls a series of functions like <em>find_user_command()</em> ,<em>find_user_command_in_path</em> , <em>find_in_path_element</em>. Each path in the PATH variable is searched for the executable that corresponds the command ‘<em>ls</em>’. BASH invokes the function <em>stat()</em> to check if there is a matching executable in each path.</p><p>Pulling the executable to memory<em> </em>:<em> </em>After all these,<em> w</em>hen when the file is located at ‘<em>/usr/bin/ls</em>’ , BASH performs <em>execve()</em> command to run the file. There are plenty of other things that needs to be achieved before the binary <em>/usr/bin/ls</em> is executed — the program needs to be read from the disk, its binary format has to be found and the proper handling code needs to be called upon through which the binary will be read into memory.</p><p>And eventually executing the command : Last but not least, the program is in memory and is about to be run when it gets a chance. Nevertheless, how are directories and files read from disk by ‘<em>ls</em>’ ? In order to do this, a list of functions are executed internally to access the final output. The <em>ls</em> utility makes use of a function to read the directory contents, which in turn invokes a system call to read the list of files in the directory by consulting the underlying filesystem’s inode entries. <em>ls</em> is formatted based on which file system the file has been specified to. As soon as all the entries have been retrieved, the system call returns . Finally, the shell prints the prompt again. Then the prompt is stored as an environment variable called &lt;code style=”background-color: rgba(0, 0, 0, 0.05);”&gt;PS1.&lt;/code&gt;Then the list of files is returned to the prompt .</p><p>Phew!! Now you know what is going on under the hood after typing <em>ls -l </em>in<em> </em>a Unix or Unix-like terminal.</p><p>Happy Bashing!!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0ea8cc682e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Static Libraries — C — Linking — Object Files]]></title>
            <link>https://medium.com/@anovacap/static-libraries-c-linking-object-files-be21bef45343?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/be21bef45343</guid>
            <category><![CDATA[computer-language]]></category>
            <category><![CDATA[c-language]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[computers]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Sun, 15 Jul 2018 20:37:36 GMT</pubDate>
            <atom:updated>2018-07-15T20:37:36.817Z</atom:updated>
            <content:encoded><![CDATA[<p>Libraries are collections of precompiled functions and variables that have been written to be reused in other programs. If several programs were being created to be combined as one they would likely use common functions. These common functions could be built as a library that each program could link as a static library (lib.a). The linking of the library comes in the last operation the compiler performs simple known as the linker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*aWAVqzrVuwAeGX7AvJtzAA.png" /></figure><p>In order to link a library, you will need to create it first. Lets say you have created several C functions each called file_1.c file_2.c and file_3.c. They need to be compiled using the -c flag with gcc like so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*SWhgXHIqGbkIe6-_75KZyQ.png" /></figure><p>The gcc -c flag only run preprocess, compile, and assemble steps, creating .o or object files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*6Ku8SnxBxQsFEbSTLuhBPg.png" /></figure><p>The next step is to archive the .o files to a .a file that you name using an archiver such as ar like so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*AegNQZDKuof5sXa00tgQcQ.png" /></figure><p>The -c flag is needed to create new libraries and the -r flag is used to replace older object files in the library, with the new object files. In order to speed up symbol-lookup inside the library, and to make sure that the order of the symbols in the library won’t matter during compilation the ranlib command is run like so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*-mpWYo5N-JHCFjtD-ItY8g.png" /></figure><p>You have now created and indexed your own static library that you can assemble into your main program like so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*Q3BKhtRqmJom2IOj6VoAXA.png" /></figure><p>The advantage of creating your own static libraries as opposed to be dependent on dynamic linked libraries — DLL’s — is, they can be tailored and shipped for exclusive use by your program and are not dependent on libraries that might change from system to system. Your program will not run if a function has updated or changed in the dynamic library leading you into dependency hell.</p><p><a href="https://en.wikipedia.org/wiki/Dependency_hell">Dependency hell - Wikipedia</a></p><p>To sum it up.</p><ul><li>Use static libraries to avoid DLL hell because the libraries are included with your executable file.</li><li>To create a static library use <em>gcc -c on the function.c files</em>, creating function.o file. Use <em>ar -rc library_name function.o</em> to archive the library, creating libray_name.a. Use <em>ran lib library_name.a</em> to to speed up symbol-lookup inside the library.</li><li>Using the library — <em>gcc main.c library_name.a </em>to assemble the executable with the library and source file linked.</li></ul><p>Thanks for reading.</p><p>Follow me on twitter <a href="https://twitter.com/anovacap">https://twitter.com/anovacap</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be21bef45343" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GCC Squared — the power of GNU C Compiler.]]></title>
            <link>https://medium.com/@anovacap/gcc-squared-the-power-of-gnu-c-compiler-b950363fa594?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/b950363fa594</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[gcc]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Thu, 21 Jun 2018 04:38:29 GMT</pubDate>
            <atom:updated>2018-06-21T04:38:29.310Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*EEdj-nW2EmL0vztdIXQ0hA.jpeg" /></figure><blockquote><strong>History</strong></blockquote><p>The original <em>GNU C Compiler</em> (GCC) is developed by Richard Stallman, the founder of the <em>GNU Project</em>. Richard Stallman founded the GNU project in 1984 to create a complete Unix-like operating system as free software, to promote freedom and cooperation among computer users and programmers.</p><blockquote>Languages etc.</blockquote><p>GCC supports many languages such as C (gcc), C++ (g++), Objective-C, Objective-C++, Java (gcj), Fortran (gfortran), Ada (gnat), Go (gccgo), OpenMP, Cilk Plus, and OpenAcc. GCC is also a key component of so-called “<em>GNU Toolchain</em>”, for developing applications and writing operating systems. The GNU Toolchain includes:</p><ol><li>GNU Compiler Collection (GCC): a compiler suit that supports many languages, such as C/C++ and Objective-C/C++.</li><li>GNU Make: an automation tool for compiling and building applications.</li><li>GNU Binutils: a suit of binary utility tools, including linker and assembler.</li><li>GNU Debugger (GDB).</li><li>GNU Autotools: A build system including Autoconf, Autoheader, Automake and Libtool.</li><li>GNU Bison: a parser generator (similar to lex and yacc).</li></ol><p>GCC is <em>portable</em> and run in many operating platforms. GCC (and GNU Toolchain) is currently available on all Unixes. They are also ported to Windows (by Cygwin, MinGW and MinGW-W64). GCC is also a <em>cross-compiler</em>, for producing executables on different platform.</p><blockquote>Tutorial</blockquote><h3>Compiling simple programs</h3><p>Say you have a file hello.c as follows :</p><pre>#include </pre><pre>void main ()<br>{<br>    printf(&quot;hello&quot;);<br>}</pre><p>You can compile and run it from the unix prompt as follows :</p><pre>% gcc hello.c</pre><p>This creates an <strong>executable</strong> called “a.out”. You can run it by typing</p><pre>% ./a.out</pre><p>at the prompt. a.out is the default name for an executable. Use the “-o” option to change the name :</p><pre>% gcc -o hello hello.c</pre><p>creates an executable called “hello”.</p><h4>Include Directories</h4><p>Sometimes the header files that you write are not in the same directory as the .c file that #include’s it. E.g. you have a structure in a file “foo.h” that resides in /homes/me/include. If I want to include that file in hello.c I can do the following on the first line of Hello.c</p><pre>#include &lt;foo.h&gt;</pre><p>Then compile with the -I option on the command line.</p><pre>$gcc -o hello hello.c -I /homes/me/include</pre><p>This basically tells gcc to look for #include’s in /homes/me/include <strong>in addition</strong> to other directories you specify with -I as the flag.</p><h4>Other options</h4><ul><li>Warnings : -Wall turns on most warnings. man gcc for more options.</li><li>Debugging : if you intend to use the debugger (gdb), also use the -g option</li><li>Optimizations : -O or -O2</li></ul><h3>Compiling multiple files</h3><p>Basic idea : compile each .c file into a .o file, then compile the .o files (along with any libraries) into an executable. One of these .c files obviously has to define the main function, or else the linker will gag.</p><p>E.g. Suppose we have main.c, foo.c and bar.c and want to create an executable fubar, and suppose further that we need the math library:</p><pre>$gcc -c foo.c<br>$gcc -c main.c<br>$gcc -c bar.c<br>$gcc -o fubar foo.o main.o bar.o -lm</pre><p>The first three commands generate foo.o, main.o and bar.o respectively. The last line links them together along with the math library.</p><h4>Libraries</h4><p>Specify library paths with the -L option. e.g. -L/usr/lib tells gcc to look for libraries in /usr/lib. As with includes, you can add as many -L’s as necessary. Specify which libraries to link with -l</p><h3>Emacs Support</h3><p>Tired of finding the line an error occurred on when compiling your C code? As with everything else in UNIX, there is good support for compiling and fixing errors in Emacs. To use this, simply type <em>meta-x compile</em> in Emacs. Then enter the gcc or make commandline you would normally use. Emacs will create a new window and execute the command in that window. When there are compilation errors, Emacs can help you go straight to them. In Emacs under X, middle-click on the error message. In Emacs under text mode, type <em>ctrl-x `</em>(ctrl-x backquote) to go to successive erroneous lines.</p><p><a href="https://courses.cs.washington.edu/courses/cse451/99wi/Section/gccintro.html">https://courses.cs.washington.edu/courses/cse451/99wi/Section/gccintro.html</a></p><p><a href="https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html#Directory-Options">https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html#Directory-Options</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b950363fa594" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the difference between a hard link and a symbolic link?]]></title>
            <link>https://medium.com/@anovacap/what-is-the-difference-between-a-hard-link-and-a-symbolic-link-286f7475270b?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/286f7475270b</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Tue, 19 Jun 2018 05:16:41 GMT</pubDate>
            <atom:updated>2018-06-19T05:16:41.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*Kx9kL-2346Q9XGxpPqP-NQ.png" /><figcaption>Diagram of Hard link and soft link.</figcaption></figure><p>The diagram above show the relationship of hard and soft links. An <strong>inode</strong> is a data structure on a filesystem on Linux and other Unix-like operating systems that stores all the information about a file except its name and its actual data.</p><p>A file in the file system is basically a link to an inode.<br>A hard link then just creates another file with a link to the same underlying inode.</p><p>When you delete a file it removes one link to the underlying inode. The inode is only deleted (or deletable/over-writable) when all links to the inode have been deleted.</p><p>A symbolic link is a link to another name in the file system.</p><p>Once a hard link has been made the link is to the inode. deleting renaming or moving the original file will not affect the hard link as it links to the underlying inode. Any changes to the data on the inode is reflected in all files that refer to that inode.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=286f7475270b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What happens when you type ls *.c in the command line?]]></title>
            <link>https://medium.com/@anovacap/what-happens-when-you-type-ls-c-in-the-command-line-ac0c75d2f88f?source=rss-f9c037323958------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac0c75d2f88f</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <dc:creator><![CDATA[Damon Nyhan]]></dc:creator>
            <pubDate>Tue, 19 Jun 2018 04:56:33 GMT</pubDate>
            <atom:updated>2018-06-19T04:56:33.159Z</atom:updated>
            <content:encoded><![CDATA[<p><em>ls</em> is one of the most commonly used commands in linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UIDdANIiXvdPHcP_kFeSIQ.png" /><figcaption>Example of ls with output.</figcaption></figure><p>The description of the <em>ls</em> command from the manual simple states — List information about the FILEs (the current directory by default). Sort entries alphabetically. Using this command is as simple as typing <em>ls </em>after the <em>$ </em>in the linux shell.</p><p>Now about <em>ls *.c.</em> Lets say you want to list the contents of a large directory filled with lots of different types of files and you want to list only the files that end in <em>.c</em>. Thats where using <em>ls.c </em>comes in handy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*foMNBINyCl6xCf0aBkZjsw.png" /><figcaption>Example of ls on a large directory.</figcaption></figure><p>By using <em>ls *.c</em> you will see the files that end in .c.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NaAUEmphXB16ON1LdfXBOg.png" /><figcaption>Example of ls *.c.</figcaption></figure><p>Simple as that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac0c75d2f88f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>