<?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 Geraldine Meneses on Medium]]></title>
        <description><![CDATA[Stories by Geraldine Meneses on Medium]]></description>
        <link>https://medium.com/@nitaly?source=rss-d229afd2bc34------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DtA93ltlAKdAgbJmBMXqyw.png</url>
            <title>Stories by Geraldine Meneses on Medium</title>
            <link>https://medium.com/@nitaly?source=rss-d229afd2bc34------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 21:23:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nitaly/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[Internet of Things (IoT)]]></title>
            <link>https://nitaly.medium.com/internet-of-things-iot-40ba5b317198?source=rss-d229afd2bc34------2</link>
            <guid isPermaLink="false">https://medium.com/p/40ba5b317198</guid>
            <category><![CDATA[internet-of-things]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Geraldine Meneses]]></dc:creator>
            <pubDate>Mon, 03 Jan 2022 03:05:31 GMT</pubDate>
            <atom:updated>2022-01-03T03:05:31.461Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UhMLJb2r6GMerltS4bAIpA.jpeg" /></figure><p>If we go into the definition of the Internet of Things, we find out that it is the concept of inter-networking of physical devices, connected devices, smart devices, and other devices embedded with electronics, software, sensors, actuators, and network connectivity that enable these objects to collect and exchange data.</p><p>For example, if books, thermostats, refrigerators, parcels, lamps, medicine cabinets, automotive parts, among others, were connected to the internet and equipped with identification devices, there would, in theory, no out-of-stock items or expired medicines; We would know exactly the location, how they are consumed in the world; the loss would become a thing of the past, and we would know what is on and what is off at all times.</p><p>Let’s imagine a world where things stop being so routine and are more automatic, that human contact is minimal and that the focus is only for its improvement and technological growth, we see a world with more possibilities.</p><h3>Four key stages in the internet of things</h3><p>Now, having the concept of IoT clear, we can delve into the 4 key stages in this process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lhLIpLz37G-NXJZk3_3XGQ.png" /></figure><ol><li><strong>Capture the data.</strong> Through sensors, IoT devices capture data from their environments. This could be as simple as the temperature or as complex a real-time video feed.</li><li><strong>Share the data.</strong> Using available network connections, IoT devices make this data accessible through a public or private cloud, as directed.</li><li><strong>Process the data.</strong> At this point, software is programmed to do something based on that data — such as turn on a fan or send a warning.</li><li><strong>Act on the data.</strong> Accumulated data from all devices within an IoT network is analyzed. This delivers powerful insights to inform confident actions and business decisions.</li></ol><h3>Privacy and security concerns in IoT</h3><p>The concerns and problems around Iot have generated the belief among users and connoisseurs that big data structures such as the internet of things or data mining, are inherently incompatible with privacy, in addition to devices, where vulnerabilities in operating systems, wireless security protocols and applications are highly complex to protect security. The Chartered Institute for Iot states that:</p><blockquote>Privacy concerns arise as a result of the compilation of detailed data on the consumption behavior of individuals and neighborhoods, up to the creation of predictive models of energy, water and transport use. It is not difficult to imagine a future information system that contains a detailed report about where citizens live, when they are at home, when they will leave or how often they watch television or use their washing machine.</blockquote><p>It may happen that the privacy security of those who use these technologies is very high and not very controllable, in this case I will comment on the 10 main security problems associated with Internet of Things (IoT) devices and that they should be taken into account account for all those who develop, create or manage IoT systems:</p><ol><li><strong>Weak, predictable, or in-code passwords</strong></li><li><strong>Insecure network services</strong></li><li><strong>Ecosystem of insecure interfaces</strong></li><li><strong>Lack of secure update mechanisms</strong></li><li><strong>Use of unsafe or outdated components</strong></li><li><strong>Insufficient privacy protection</strong></li><li><strong>Unsafe data transfer and storage</strong></li><li><strong>Lack of management controls</strong></li><li><strong>Unsafe default settings</strong></li><li><strong>Lack of hardening</strong></li></ol><p>A real case occurred with a recognized company, the BBC comments on the case that occurred with Amazon’s voice assistant, a couple in Portland, Oregon, United States, used to joke about whether Alexa, the virtual assistant of the speaker made by Amazon, could be listening to their conversations … but the joke It came to an end when they discovered that indeed the machine had registered and also sent what they were talking about inside their house. Messages that actually reached one of the contacts in the phone book registered with Alexa, to which Amazon responded; — what has happened is a string of inopportune coincidences</p><p>To overcome this problem, the Chartered Institude for Iot suggests that general IoT infrastructures require broad public support that can only be achieved through broad citizen engagement and action to help them. Understand the purpose and ramifications of the proposed developments.</p><p>In conclusion, as in everything else, technology is a very wide world and that can encompass everything that one can imagine, errors occur that based on experience are corrected and progress is made, in a world where we are all connected, more than in entertainment, the advancement of the productivity of repetitive things without the need for much human contact, can be a new advance for humanity. It is not said that it will be easy, but over time we will understand that they will be necessary, created in the correct way for the good of people without exceeding the limits of control.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40ba5b317198" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Picture is Worth 1,500 Words (Recursion in C)]]></title>
            <link>https://nitaly.medium.com/a-picture-is-worth-1-500-words-recursion-in-c-f0e5e5fb2867?source=rss-d229afd2bc34------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0e5e5fb2867</guid>
            <category><![CDATA[infografia]]></category>
            <category><![CDATA[recursion]]></category>
            <category><![CDATA[recursion-in-c]]></category>
            <category><![CDATA[lenguaje-c]]></category>
            <category><![CDATA[infographics]]></category>
            <dc:creator><![CDATA[Geraldine Meneses]]></dc:creator>
            <pubDate>Tue, 02 Nov 2021 04:41:40 GMT</pubDate>
            <atom:updated>2021-11-02T17:48:01.105Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dsnBlFbISzHHJLqjqRAmGQ.png" /><figcaption>Recursion in C</figcaption></figure><figure><img alt="Infographic explaining the recursion process in C" src="https://cdn-images-1.medium.com/max/800/1*KSELzcsQNo3QXF24OAkEdA.png" /><figcaption>Explanation of the recursion process in C</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0e5e5fb2867" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python | Mutable, Immutable]]></title>
            <link>https://nitaly.medium.com/python-mutable-immutable-2790e5740496?source=rss-d229afd2bc34------2</link>
            <guid isPermaLink="false">https://medium.com/p/2790e5740496</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[everything-is-object]]></category>
            <dc:creator><![CDATA[Geraldine Meneses]]></dc:creator>
            <pubDate>Wed, 13 Oct 2021 22:02:36 GMT</pubDate>
            <atom:updated>2021-10-14T02:57:34.255Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ERLXo4qtjKdBlWA6.png" /></figure><p>Before reading the concepts, we must understand that everything, absolutely everything in Python is an object, and when we have it clear that we can understand that objects can be both mutable and immutable.</p><p>Lets dive deeper into the details of it… Since everything in Python is an Object, every variable holds an object instance. When an object is initiated, it is assigned a unique object id. Its type is defined at runtime and once set can never change, however its state can be changed if it is mutable. Simple put, a <strong>mutable</strong> object can be changed after it is created, and an <strong>immutable</strong> object can’t.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QGcofc_LI6kRlZPY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/0*qJCbJ01Ypll726IX.png" /></figure><p>Now comes the question, how do we find out if our variable is a mutable or immutable object. For this we should understand what ‘ID’ and ‘TYPE’ functions are for.</p><h3>ID and TYPE</h3><p>The built-in function <strong>id</strong>() returns the identity of an object as an integer. This integer usually corresponds to the object’s location in memory, although this is specific to the Python implementation and the platform being used. The <strong>is</strong> operator compares the identity of two objects. For example</p><blockquote>SYNOPSIS: <strong>id(object)</strong></blockquote><pre>&gt;&gt;&gt; hi = &quot;Hello&quot;<br>&gt;&gt;&gt; name = &quot;Gera&quot;<br>&gt;&gt;&gt; id(hi)<br>140161527368240<br>&gt;&gt;&gt; id(name)<br>140161527369200<br>&gt;&gt;&gt; print(hi is name)<br>False<br>&gt;&gt;&gt; name = &quot;Hello&quot;<br>&gt;&gt;&gt; print(hi is name)<br>True<br>&gt;&gt;&gt; id(name)<br>140161527368240<br>&gt;&gt;&gt;</pre><p>The built-in function type() returns the type of an object. Lets look at a simple example</p><blockquote>SYNOPSIS : <strong>type(object)</strong></blockquote><pre>&gt;&gt;&gt; type(1)<br>&lt;class &#39;int&#39;&gt;<br>&gt;&gt;&gt; type(&quot;Holberton&quot;)<br>&lt;class &#39;str&#39;&gt;<br>&gt;&gt;&gt; a = 15<br>&gt;&gt;&gt; type(a)<br>&lt;class &#39;int&#39;&gt;<br>&gt;&gt;&gt;</pre><p>We have now seen how to compare two simple string variables to find out the types and id’s .So using these two functions, we can check to see how different types of objects are associated with variables and how objects can be changed .</p><h3>Mutable Objects</h3><p>Some of the <strong>mutable</strong> data types in Python are list,<strong> </strong><strong>dictionary</strong>,<strong> </strong><strong>set</strong> and <strong>user-defined classes</strong></p><p>A practical example to find out the mutability of object types</p><pre>&gt;&gt;&gt; a = [1, 2, 3]<br>&gt;&gt;&gt; id(a)<br>140226822881600<br>&gt;&gt;&gt; a.append(4)<br>&gt;&gt;&gt; a<br>[1, 2, 3, 4]<br>&gt;&gt;&gt; id(a)<br>140226822881600<br>&gt;&gt;&gt; a[2] = 5<br>&gt;&gt;&gt; a<br>[1, 2, 5, 4]<br>&gt;&gt;&gt; id(a)<br>140226822881600<br>&gt;&gt;&gt;</pre><p>In this example, a is a list of three integers. We can append the integer 4 to the end of this list. Running the id function before and after appending 4 shows that it is the same list both before and after. We can also use item assignment to change the value of one of the items in our list. I used item assignment to set the value of element #2 to 5. Printing id again shows that we are working on the same list.</p><h3>Immutable Objects</h3><p><strong>Immutable</strong> objects are objects that cannot be changed. In Python, this would include int, float, string, <strong>user-defined classes</strong>, and more. These data types cannot be modified. This can be shown in the following example with a string:</p><pre>&gt;&gt;&gt; a = &quot;Holberton&quot;<br>&gt;&gt;&gt; a[2] = &quot;x&quot;<br>Traceback (most recent call last):<br>  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>TypeError: &#39;str&#39; object does not support item assignment<br>&gt;&gt;&gt;</pre><p>We cannot change element #2 in the string “Holberton” to the letter x because strings are immutable. They cannot be changed. Let’s take a look at another example:</p><pre>&gt;&gt;&gt; a = &quot;Holberton&quot;<br>&gt;&gt;&gt; b = &quot;Holberton&quot;<br>&gt;&gt;&gt; a == b<br>True<br>&gt;&gt;&gt; id(a)<br>140226821903600<br>&gt;&gt;&gt; id(b)<br>140226821903600<br>&gt;&gt;&gt;</pre><p>In this example, strings a and b are both set to Holberton. Because strings are immutable in Python, they will both point to the same space in memory storing this string. We can test if two strings have the same value using the double equal sign, ==. We can test if two strings refer to the same object using the is operator. This tells us that a and b both refer to the same object. This can also be verified by running the id() function on both strings. Because the same string has two different names, the string is said to be aliased.</p><h3>Preallocation in Python</h3><p>In Python, upon startup, Python3 keeps an array of integer objects, from -5 to 256. For example, for the int object, marcos called NSMALLPOSINTS and NSMALLNEGINTS are used:</p><pre>#ifndef NSMALLPOSINTS<br>#define NSMALLPOSINTS           257<br>#endif<br>#ifndef NSMALLNEGINTS<br>#define NSMALLNEGINTS           5<br>#endif<br>#if NSMALLNEGINTS + NSMALLPOSINTS &gt; 0<br>/* References to small integers are saved in this array so that they<br>   can be shared.<br>   The integers that are saved are those in the range<br>   -NSMALLNEGINTS (inclusive) to NSMALLPOSINTS (not inclusive).<br>*/<br>static PyIntObject *small_ints[NSMALLNEGINTS + NSMALLPOSINTS];<br>#endif<br>#ifdef COUNT_ALLOCS<br>Py_ssize_t quick_int_allocs;<br>Py_ssize_t quick_neg_int_allocs;<br>#endif</pre><p>What does this mean? This means that when you create an int from the range of -5 and 256, you are actually referencing to the existing object.</p><h3>How objects are passed to Functions</h3><p>Its important for us to know difference between mutable and immutable types and how they are treated when passed onto functions .Memory efficiency is highly affected when the proper objects are used.</p><p>For example if a mutable object is called by reference in a function, it can change the original variable itself. Hence to avoid this, the original variable needs to be copied to another variable. Immutable objects can be called by reference because its value cannot be changed anyways. Let’s look at an example with a function that increments an int, an immutable object:</p><pre>&gt;&gt;&gt; def increment(a):<br>...     a += 1<br>...     print(&quot;id of a:&quot; , id(a))<br>...     return a<br>...<br>&gt;&gt;&gt; x = 1<br>&gt;&gt;&gt; y = increment(x)<br>id of a: 9788640<br>&gt;&gt;&gt; print(&quot;x: &quot;, x)<br>x:  1<br>&gt;&gt;&gt; print(&quot;y: &quot;, y)<br>y:  2<br>&gt;&gt;&gt; print(&quot;id of x: &quot;, id(x))<br>id of x:  9788608<br>&gt;&gt;&gt; print(&quot;id of y: &quot;, id(y))<br>id of y:  9788640<br>&gt;&gt;&gt;</pre><p>The function increment() takes an integer and increments it. It will also print out the id of the argument. We store the value 1 in the variable x and pass x as an argument to the increment function. Afterwards, we print the values and addresses of both x and y. We can see here that y holds the value 2, which is what we expect from a function that increments the number 1. Notice that the id of y matches the id of a inside the increment function. This is because both y and a are variables pointing at the same integer object.</p><p>Let’s look at another example using a mutable data type, a list:</p><pre>&gt;&gt;&gt; def add(argument):<br>...     argument.append(4)<br>...<br>&gt;&gt;&gt; list1 = [1, 2, 3]<br>&gt;&gt;&gt; list2 = list1<br>&gt;&gt;&gt; print(&quot;list1: &quot;, list1)<br>list1:  [1, 2, 3]<br>&gt;&gt;&gt; print(&quot;list1 id: &quot;, id(list1))<br>list1 id:  140226822881600<br>&gt;&gt;&gt; print(&quot;list2: &quot;, list2)<br>list2:  [1, 2, 3]<br>&gt;&gt;&gt; print(&quot;list2 id: &quot;, id(list2))<br>list2 id:  140226822881600<br>&gt;&gt;&gt; add(list1)<br>&gt;&gt;&gt; print(&quot;list1: &quot;, list1)<br>list1:  [1, 2, 3, 4]<br>&gt;&gt;&gt; print(&quot;list1 id: &quot;, id(list1))<br>list1 id:  140226822881600<br>&gt;&gt;&gt; print(&quot;list2: &quot;, list2)<br>list2:  [1, 2, 3, 4]<br>&gt;&gt;&gt; print(&quot;list2 id: &quot;, id(list2))<br>list2 id:  140226822881600<br>&gt;&gt;&gt;</pre><p>Mutable data types like lists and dicts are also passed by reference. If the value of a mutable data type is changed inside a function, the value is also changed in the caller. This is true regardless of the name of the argument.</p><p>Mutable data types like lists and dicts are also passed by reference. If the value of a mutable data type is changed inside a function, the value is also changed in the caller. This is true regardless of the name of the argument.</p><p>In this example, we created a list object called list1 and assigned the same object to the variable list2. Both list1 and list2 point to the same memory where the actual list object [1, 2, 3] is stored. We pass the list1 variable as an argument to the function add(). In this function, we append the list1 object element through the argument simply called argument. The actual object list1 is changed when we change the value in the function. The value of list2 also changes when this function is called. This is because the list1 and list2 variables both point to the same list object. The id of list1 and list2 do not change because lists are mutable and can therefore be changed. Therefore, changing a list object modifies the original object value and doesn’t create a new object.</p><p>Variables are handled completely differently in C and Python at the most fundamental level. It’s important to understand the differences to avoid confusion.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2790e5740496" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic libraries in C: Definition, explanation and creation]]></title>
            <link>https://nitaly.medium.com/dynamic-libraries-in-c-definition-explanation-and-creation-bbb34bc7698f?source=rss-d229afd2bc34------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbb34bc7698f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[lenguaje-c]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[libraries-in-c]]></category>
            <dc:creator><![CDATA[Geraldine Meneses]]></dc:creator>
            <pubDate>Sat, 25 Sep 2021 02:47:26 GMT</pubDate>
            <atom:updated>2021-09-25T02:47:26.852Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Dynamic libraries" src="https://cdn-images-1.medium.com/max/500/1*2A9orAHwBZU_HeygdEwE3Q.gif" /><figcaption>Dynamic libraries</figcaption></figure><h3>Why use libraries in general and how they work in c?</h3><p>Libraries in C are not unlike public libraries in cities, towns, or neighborhoods. A public library provides access to a multitude of information in various media forms to the public for access and use. Functions in a C library can be used and accessed by programmers to create several different programs.</p><p>As a programmer, you may find yourself using the same function or functions repeatedly. In this case, it is best to put this function or functions in a library to speed up the compilation of the program. C libraries store files in object code; during the linking phase of the <a href="https://nitaly.medium.com/steps-to-compile-with-gcc-84d7cda311a">compilation process</a> files in object code are accessed and used. It is faster to link a function from a C library than to link object files from a separate memory sticks or discs.</p><figure><img alt="compilation of libraries in c" src="https://cdn-images-1.medium.com/max/479/0*CxP0jOV2RVrkMGpk.gif" /><figcaption>compilation of libraries in c</figcaption></figure><h3>How to create them (Linux only)</h3><p>To make the process of creating a dynamic library, we will use the following files:</p><pre><strong>root@c698ec171c6e:/holberton/dynamic_libraries# </strong>ls<br>0-isupper.c  0-strcat.c  1-isdigit.c  1-strncat.c  2-strlen.c   3-islower.c  3-strcmp.c  4-isalpha.c  5-strstr.c  9-strcpy.c<br>0-memset.c   100-atoi.c  1-memcpy.c   2-strchr.c   2-strncpy.c  3-puts.c     3-strspn.c  4-strpbrk.c  6-abs.c     _putchar.c</pre><p>To get started, we must first create the object files with the command gcc -fPIC -c *.c</p><pre><strong>root@c698ec171c6e:/holberton/dynamic_libraries# </strong>gcc -fPIC -c *.c<br><strong>root@c698ec171c6e:/holberton/dynamic_libraries#</strong> ls *.o<br>0-isupper.o  0-memset.o  100-atoi.o   1-memcpy.o   2-strchr.o  2-strncpy.o  3-puts.o    3-strspn.o   4-strpbrk.o  6-abs.o     mat.o<br>0-main.o     0-strcat.o  1-isdigit.o  1-strncat.o  2-strlen.o  3-islower.o  3-strcmp.o  4-isalpha.o  5-strstr.o   9-strcpy.o  _putchar.o</pre><p>As you may have noticed, this time we create the object files with the <strong>-fPIC</strong> flag. This flag stands for <strong><em>Position Independent Code</em></strong>, a feature required by shared libraries.</p><p>In the next step we will create the library called <strong>libdynamic.so</strong>:</p><pre><strong>root@c698ec171c6e:/holberton/dynamic_libraries# </strong>gcc -shared -Wl<strong>, -</strong>soname , libdynamic.so -o libdynamic.so * .o</pre><p>The <strong>-shared</strong>key tells the compiler to produce a shared object that can then be linked with other objects to form an executable. <strong>-Wl</strong> flag passes an option to the linker with the following format, in the case of our example, it sets the name of the library, as it will be passed to the linker. <strong>-Wl, options</strong>, in case of our example it sets the name of library, as it will be passed to the linker.</p><pre><strong>root@c698ec171c6e:/holberton/dynamic_libraries# </strong>ls *.so<br>libdynamic.so</pre><p>As the result, we’ve got the library that is ready to be used.</p><h3>Static vs Dynamic</h3><p>The concept of a library is powerful because it allows an end user to link functions via their object file’s during either run-time or compile time — this differs <strong><em>depending on the type of library</em></strong> you create.</p><p><strong>Static library</strong> is a collection of object files, while <strong>dynamic</strong> or <strong>shared</strong> <strong>library</strong> is a collection of functions compiled and stored in an executable <strong><em>with purpose of being linked by other programs</em></strong> at run-time.</p><p>Dynamic libraries provide a means to use code that can be loaded anywhere in the memory. Once loaded, the library code can be used by any number of programs. This way the size of programs using dynamic library and the memory footprint can be kept low as a lot of code is kept common in form of a shared library.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbb34bc7698f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What happens when you type ls -l *.c in the shell]]></title>
            <link>https://nitaly.medium.com/what-happens-when-you-type-ls-l-c-in-the-shell-74ea40e82af0?source=rss-d229afd2bc34------2</link>
            <guid isPermaLink="false">https://medium.com/p/74ea40e82af0</guid>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[holberton-school]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Geraldine Meneses]]></dc:creator>
            <pubDate>Thu, 19 Aug 2021 18:45:43 GMT</pubDate>
            <atom:updated>2021-08-26T17:23:06.548Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*leIEw6MqJgBte4v0Iy4_eg.gif" /></figure><p>Let’s start by wondering …</p><h3><strong>What is Shell?</strong></h3><p>In computing, the shell or command interpreter is the computer program that provides a user interface to access the services of the operating system.</p><p>Now in Linux the Shell is in charge of establishing communication between the kernel and the user of the Linux System, that is, it is an interface with our Operating System. Then thanks to him we will be able to give the necessary orders so that our computer system performs the tasks we need.</p><figure><img alt="shell and kernel process diagram, starting with the user’s request and showing the process path that that command does to return a result" src="https://cdn-images-1.medium.com/max/960/1*cGCmtdxUfXjtIQjSjdf2zQ.jpeg" /><figcaption>Shell and Kernel process diagram</figcaption></figure><h3><strong>What are shell commands?</strong></h3><p>Before learning about some of the commands available in the Shell, you must be very clear about the tasks to be carried out, that is, you must differentiate between administration tasks and regular use of the system.</p><p>Commands are invoked by name and options or parameters are passed to them by means of the minus sign “<strong>-</strong>” followed by one or more letters. For example <strong><em>ls -la</em></strong>.</p><h3><strong>ls -l *.c</strong></h3><p><strong><em>ls</em></strong>: It shows the names of the files and subdirectories contained in the directory you are in. Only the names of the files are obtained, without any other information.<br><strong><em>ls -l</em></strong>: This is the long list option. It shows all the information of each file including. Protections, size and date of creation or of the last change introduced.<br><strong><em>*</em></strong>: Represents any set or sequence of characters.</p><p>If we only write <strong><em>ls</em></strong> in the terminal, we will end up listing all the files (not hidden) that are in the current directory:</p><pre><strong>root@c698ec171c6e:/home/simple_shell#</strong> ls<br>AUTHORS        e      e_p.c           m     main.c              match.c  p          shell    simpleshell.h         v<br>brokentoken.c  env.c  execute_path.c  main  man_1_simple_shell  o        README.md  shell.c<br><strong>root@c698ec171c6e:/home/simple_shell#</strong></pre><p>We can see that we have files of all kinds, but what if I add another parameter? now I want to add the command <strong><em>-l</em></strong> according to the previous table, this added command should list the files with the detailed information, then the result would be something like this:</p><pre><strong>root@c698ec171c6e:/home/simple_shell#</strong> ls -l<br>total 3052<br>-rw-r--r-- 1 root root     510 Aug 17 19:39 brokentoken.c<br>-rwxr-xr-x 1 root root   16936 Aug 18 17:42 e<br>-rw-r--r-- 1 root root     184 Aug 17 19:51 env.c<br>-rw-r--r-- 1 root root     552 Aug 17 20:31 e_p.c<br>-rw-r--r-- 1 root root     559 Aug 18 12:28 execute_path.c<br>-rwxr-xr-x 1 root root   17400 Aug 17 19:13 m<br>-rwxr-xr-x 1 root root   17560 Aug 18 11:58 main<br>-rw-r--r-- 1 root root    1467 Aug 18 12:50 main.c<br>-rw-r--r-- 1 root root     728 Aug 14 18:50 match.c<br>-rwxr-xr-x 1 root root   16840 Aug 16 15:34 o<br>-rw-r--r-- 1 root root 2952592 Aug 17 20:32 p<br>-rw-r--r-- 1 root root    2016 Aug 13 16:32 README.md<br>-rwxr-xr-x 1 root root   17264 Aug 17 13:37 shell<br>-rw-r--r-- 1 root root    1526 Aug 17 16:45 shell.c<br>-rw-r--r-- 1 root root     615 Aug 18 11:37 simpleshell.h<br>-rwxr-xr-x 1 root root   16696 Aug 17 19:51 v<br><strong>root@c698ec171c6e:/home/simple_shell#</strong></pre><p>Good! We have a list with all the information of each file, if we read from right to left we can say that this command helps us to see detailed information of the files. In the following image, each part is named:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Guf6asszEMKaBYPPXHDkg.jpeg" /><figcaption>Description of the detail of a file</figcaption></figure><p>Now, the<strong> <em>ls</em></strong> command admits the substitution characters or meta characters such as the symbol <strong><em>*</em></strong>, now when we join these commands and include an extension in this case the <strong><em>.c</em></strong> it would be:</p><pre><strong>root@c698ec171c6e:/home/simple_shell#</strong> ls -l *.c</pre><p>And the result of this would be the long list of all files that end with the extension <strong><em>.c</em></strong>:</p><pre><strong>root@c698ec171c6e:/home/simple_shell#</strong> ls -l *.c<br>-rw-r--r-- 1 root root  510 Aug 17 19:39 brokentoken.c<br>-rw-r--r-- 1 root root  184 Aug 17 19:51 env.c<br>-rw-r--r-- 1 root root  552 Aug 17 20:31 e_p.c<br>-rw-r--r-- 1 root root  559 Aug 18 12:28 execute_path.c<br>-rw-r--r-- 1 root root 1467 Aug 18 12:50 main.c<br>-rw-r--r-- 1 root root  728 Aug 14 18:50 match.c<br>-rw-r--r-- 1 root root 1526 Aug 17 16:45 shell.c<br><strong>root@c698ec171c6e:/home/simple_shell#</strong></pre><p>We can notice that it does not take into account the other files that were listed in the first command when it was only <strong><em>ls -l</em></strong> and that it only showed all the files that contained a <strong><em>.c</em></strong> extension.</p><p>This would be all the Command would do, but it doesn’t end here…</p><h3>How does the Shell work from another perspective?</h3><p>When we write a command in the terminal in this case <strong><em>ls -l</em></strong> it happens to be stored in a <strong><em>getline</em></strong> this function reads an entire line of stream, storing the text (including the new line character and the termination character) in a buffer its prototype is: <strong><em>ssize_t getline (char ** lineptr, size_t * n, FILE * stream);</em></strong>.</p><p>Once the command is written and stored in the <strong><em>getline</em></strong> we pass it through the<strong><em>strtok</em></strong> function. This function helps us to separate the string by the assigned delimiter, in our case assigning the space as the delimiter, so that each command is stored in separate memory spaces and arguments can be evaluated. The prototype of s<strong><em>trtok</em></strong> is: <strong><em>strtok (string, delimiter);</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TOXdtGyG5Y5bnG1HMKl3dw.gif" /><figcaption>Gif about getline and strtok functions</figcaption></figure><p>once the strings have been divided, we proceed to evaluate the first element of memory in the paths of the environment variables <strong><em>PATH</em></strong> with the functions <strong><em>execve</em></strong> and <strong><em>fork</em></strong>.</p><p><strong><em>exeve</em></strong> is a function that executes the program indicated by <strong><em>filename</em></strong> and must be an executable binary. In the second case, the interpreter must be a valid path name for an executable that is not itself a script and that will be executed with the arguments [arg] (optional) plus the file filename to interpret, its prototype is: <strong><em>int execve (const char * filename, const char * argv [], const char * envp []);</em></strong></p><p><strong><em>fork</em></strong> is used to start a new process within the main process, this second process is known as the child and the main process is known as the parent. At this point the <strong><em>fork</em></strong> works once the parent process is executed, it creates a second execution (child) where that child process executes an internal function while the parent waits with the wait command for the child process to finish to continue its function, there are scenarios where the child process does not function and returns 3 possible results:</p><ul><li><strong>-1</strong> = Creation of child process was unsuccessful.</li><li><strong>0</strong> = Child process is executed</li><li><strong>1</strong> = Parent process is executed</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*x5rAX8-XYGaAh6UgaGnOfw.jpeg" /><figcaption>Flowchart explaining the fork () process</figcaption></figure><p>Once the command path is obtained by going through the environment through the <strong><em>PATH</em></strong>, it executes its file returning the command function in this case <strong><em>ls</em></strong> and evaluating if it has more arguments marked with the symbol “<strong><em>-”</em></strong>, the executable file will return what the command calls in our case the long list <strong><em>-l.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_ot_dJSOnQpm6YLVpeydQ.gif" /><figcaption>Touring PATH</figcaption></figure><p>This is what the Shell executes internally when you give it a command! We invite you to take The Complete List of Shell Commands and try to combine the commands, so that you can get to know and learn this language more easily!</p><p><em>This blog is designed and written by:<br></em><a href="https://medium.com/u/7ec166edc4b0"><em>Diana Carhuamanta</em></a><em> and </em><a href="https://medium.com/u/d229afd2bc34">Geraldine Meneses</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74ea40e82af0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Steps to compile with GCC]]></title>
            <link>https://nitaly.medium.com/steps-to-compile-with-gcc-84d7cda311a?source=rss-d229afd2bc34------2</link>
            <guid isPermaLink="false">https://medium.com/p/84d7cda311a</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[compilation]]></category>
            <category><![CDATA[gcc]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Geraldine Meneses]]></dc:creator>
            <pubDate>Tue, 22 Jun 2021 04:26:34 GMT</pubDate>
            <atom:updated>2021-06-22T20:00:17.699Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="GCC Compiler" src="https://cdn-images-1.medium.com/max/1024/1*u8kQSkwdnOnb-qfvY0OVMw.png" /></figure><p>The word compile means to translate programming code into machine executable code. People speak a language superior to a programming language and that has its advantage and its disadvantage, that is why in the evolution of programming higher-level programming languages such as Python, Ruby and, in this case, the programming language were developed C.</p><p><strong>What is GCC?</strong></p><p>Its acronym is “GNU Compiler Collection” is an integrated compiler of the GNU project for C, C ++, Objective C and Fortran. Its function is to receive a source program in any of the aforementioned languages and generate a binary executable program that would be machine language.</p><p><strong>But why compile?</strong></p><p>Very simple, when we write a command where we order the computer to do something, it itself does not read it, it needs to see it in its language to be able to give the expected result, that is why we do the compilation, so that what we program it is converted to machine language. an example in the following image:</p><figure><img alt="2. Compilation steps" src="https://cdn-images-1.medium.com/max/1024/1*VSBloOMZGDhdrRskgm3rUQ.png" /></figure><p><strong>What are the preprocessor, compiler, assembler, and linker?</strong></p><ul><li>The <strong>preprocessor</strong> is the one that “prepares” (modifies) the source code before being translated into machine language using the <em>gcc -E</em> command. The changes are made by interpreting those lines of code that begin with the symbol “#”. The use of these directives is to define the code in the language of the processor.</li></ul><p>In the example we use the directive #include &lt;stdio.h&gt; where #include is the directive followed by a filename which in this case is &lt;stdio.h&gt;.<br>You must bear in mind that if the file is between the symbols “&lt;” and “&gt;” the preprocessor will search the internal directories of the system. This version is used to include files given by the system.</p><p>But if the file is enclosed in double quotes (“ ”) then it looks in the directory in which it is being compiled. This version of the directive is used to include files that the user has written.<br>The extension “.h” is used for files that are included in a program with this directive.</p><ul><li>The <strong>Compiler </strong>analyzes the source code giving a detailed check for its correct execution, this process converts the commands to machine language so that the processor can read in detail its lexicon, grammar analysis, semantic analysis and if there is an error it will stop the compilation process, the The compiler is activated with the <em>gcc -S</em> command.</li></ul><p>For the server to tell you what the errors were, write the -wall option that activates all the most common notices in your command. Later we will talk about the error messages that usually appear.</p><ul><li>The <strong>Assembler </strong>at this point makes the language binary so that the machine can read it correctly, after going through the previous stages we know that our code is correct to be executed later here we just link it and assemble it using the <em>gcc -c</em> command for later be able to execute it.</li><li>The <strong>Link </strong>makes our source code be read by the machine in binary language and execute the requested action, to convert our file to executable we use the command <em>gcc &lt;file.c&gt; -o &lt;file&gt;</em>. At this last point is where we can see the result of the written code executed by the machine, it is necessary to go through the previous processes to detect and correct errors that may appear in our code and the machine can read everything correctly.</li></ul><p><strong>Compiler errors and warnings</strong></p><p>The compiler is the program that, given a set of code files, translates them and generates a ready-to-run file. But for this translation to be possible, the program must meet the requirements imposed by the programming language. The type of checks that are made in this translation depends on both the programming language and the compiler itself. When something is detected in the program that is not allowed by the standards of the language, the compiler displays a message and the translation stops.</p><p>The compiler itself will not tell us exactly what errors we have in the process, but it will tell us the specific anomaly that the compiler has detected. These can be read using the <em>gcc -wall</em> command</p><p>but be very careful always compile with the -Wall option and do not consider the correct program until all warnings have been removed.</p><h3>build process:</h3><p>In this process we will compile with the blog.c file that will contain the code:</p><figure><img alt="3. source code" src="https://cdn-images-1.medium.com/max/279/0*p8zTKM7cuVWW7Tz6" /></figure><ol><li><strong>Processor.</strong> In this first stage, the compiler compiles the header file of the C program with the command:</li></ol><p>$ gcc -E blog.c -o blog.i</p><p>This in order to do some preparations before compilation. The<strong> -E</strong> command only Solo preprocesses; it does not compile, assemble or link, be very careful with that command.</p><p>The <strong>-o</strong> command specifies the name of the output file as file, it is for the output file option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/0*_cqdSdfM80sPR0Qo" /></figure><p>resulting in this machine reading:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/0*kBq20kG1Ryhhx9tp" /></figure><p>2. <strong>Compilation.</strong> In this second stage, the compiler mainly performs lexical analysis, grammar analysis, semantic analysis, etc. After checking for errors, translate the code into assembly language.</p><p>$ gcc -S blog.i -o blog.s</p><p>Each declaration in an assembly language program is described in a standard text format. A low-level machine language instruction</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/0*HoUFSsBRUFAoel-L" /></figure><p>The <strong>-S</strong> command does not assemble or link, its only function is compilation, it can compile preprocessed files into assembly source code. This is how the machine is processing it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/0*XXlj7_KsR1jOAvyA" /></figure><p>3. <strong>Assembly.</strong> In this third stage the file goes through changes, becoming object code, at this level the code is already being transformed into machine language, the command would be:</p><p>$ gcc -c blog.s -o blog.o</p><p>Where the <strong>-c</strong> command compiles and assembles, but does not link the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/0*MmG3whJrZOXl2A6y" /></figure><p>At this point the blog.o file is a binary file whose byte encoding is machine language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ndMb-UhECAgpsWyU" /></figure><p>4. <strong>Link</strong>. In this fourth and last stage, we are going to create the executable code, giving the corresponding modification so that our code completes its stage of changes and ends up being machine language in its entirety. All this is executed with the command:</p><p>$ gcc blog.o -o blog</p><p>When completing the code in our directory we will find our file already in the execution state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/0*rTOlxPYJBrXrSyxg" /></figure><p>To run it just type:<br>$ ./blog</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/0*_RcbbvlyB5MukGZz" /></figure><p>Inside we will not see our command since the folders were modifying their interior until they became machine language:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/0*irjDot-9v75cAroM" /></figure><p>This is how you will see all the changes in the .c file where the green one is the already executable file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/0*XI7LsMMmQhiHdzzg" /></figure><p>This is the compilation process step by step with the gcc command. I hope the information is very useful, do not forget to leave a comment or any questions :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84d7cda311a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>