<?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 Diana Gureev on Medium]]></title>
        <description><![CDATA[Stories by Diana Gureev on Medium]]></description>
        <link>https://medium.com/@dianagureev?source=rss-7e069eb5360d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fblGcCLGgdz2Pb2tKkrmxA.jpeg</url>
            <title>Stories by Diana Gureev on Medium</title>
            <link>https://medium.com/@dianagureev?source=rss-7e069eb5360d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 03:23:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dianagureev/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[Unlocking the Magic of Figma: A Non-Designer’s Guide to Creating Simple Website Prototypes]]></title>
            <link>https://medium.com/@dianagureev/unlocking-the-magic-of-figma-a-non-designers-guide-to-creating-simple-website-prototypes-e62ac494ab90?source=rss-7e069eb5360d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e62ac494ab90</guid>
            <category><![CDATA[figma]]></category>
            <dc:creator><![CDATA[Diana Gureev]]></dc:creator>
            <pubDate>Sun, 03 Dec 2023 09:29:11 GMT</pubDate>
            <atom:updated>2023-12-03T09:37:44.656Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*6aoxXHGYdYLFFPuz" /><figcaption>Photo by <a href="https://unsplash.com/@theshubhamdhage?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Shubham Dhage</a> on <a href="https://unsplash.com/photos/a-white-square-button-with-a-multicolored-object-on-it-4tXfdctTcWs?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>I am a junior full-stack developer, and now I am creating a lot of projects for my portfolio. I want them to be built well — with some features, interesting elements, and so on. But more than that, I want my workflow to be consistent. From my point of view it is not cool to code something unpredictable. With an easy prototype I can think about my code, all the features and even text, images and fonts before I even open the VSCode. And… it is much easier than you think!</p><p>In this article, I will show you a non-professional way to make an interesting prototype in Figma to improve your learning projects.</p><p>*As an example I will use the project I made for one of the Hackathons at the Developer Institute.</p><h3>Start</h3><p>Getting started with Figma is easier than saying “Quidditch”. Click the “Get started for free” button and you are in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6MVYS-dKVIuvMYf6eKKDaw.png" /></figure><p>Now you should see a black field with nothing and this is where we start.</p><h3>Inspiration</h3><p>You might think that now I will teach you all these infinity tools of Figma, but I am not. All my projects I start with the Figma community where you can find a lot of good ideas on how to do your projects. And besides that — free icons, illustrations, good color combinations, font suggestions and so on.</p><p>So don’t hesitate to go and… grab some nice elements for your future project.</p><blockquote><em>Don’t forget to choose only free examples (not sure if we can really use them on a paid project, but for studying, why not?)</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*O54TVXO9uHZjdTn1GsudsA.png" /></figure><p>To copy the items and bring them to your Figma desk, you need to literally click on the item and use Ctrl+C Ctrl+V. You can also zoom in and out on the desk using your mouse wheel + Ctrl. Or move horizontally across the board using the mouse wheel + Shift.</p><h3>Step one: Create a main Frame</h3><p>And this is where we start with the tools. To make a website, we need to create a frame that will represent a screen. So we go to the Frame tool and choose the right size on the right toolbar:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*f3UNRfJH4VUCgaVVschzlg.png" /></figure><p>Select the size you need. For example, I choose MacBook Air and that’s what I get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGCfQg0emOyxoU_qnFVbAw.png" /></figure><p>Work-ready frame. At this point, you probably already have your color scheme and some illustrations to work with. Mine looks like this most of the time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TEyJnOc3G9xlwL-qqsXqeQ.png" /></figure><h3>Step two: Navigation bar</h3><p>I start with body coloring and navbar. I prefer not to guess but to measure. On the popular websites the navbar height is from 50px to 65px. So I just go with what looks good to me in that range of height. Let us say 65px.</p><p>When I do the coding, I will have the height set to 65px — nothing to do with guesswork.</p><p>To make the navbar, we’ll take the Rectangle tool and make it 65px high. We’ll color it the way we want and then stretch it to the width of the frame. To see the width of your frame, just click on it and look to the right:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YaS095K1fb84GqP9SSUa_Q.png" /></figure><p>In our case, the screen is 1728 px. To set the width of the rectangle, click on it again and set the width to 1728px.</p><p>Now it is time to drag it into a frame to its place at the top of the page.</p><blockquote><em>If you can’t drag it properly and you see a little gap between frame borders and nav, like 1px or so, don’t forget that you can just move the element to the left (or in any direction) with arrows ← → or you can zoom in and drag it easily with the mouse — Ctrl and scroll the mouse wheel forward (or backward to zoom out).</em></blockquote><h3>Step three: Grid</h3><p>After the navbar took its place, its time to distribute the page space for the elements. I prefer to use a layout grid. It is a good tool also for developers, because you know how to work with your grid or how your flex will look like.</p><ul><li>Click the frame.</li><li>Click the + next to Layout Grid.</li><li>Click on the icon near Grid and choose columns (I prefer 12 with 10 in the gutter — you can use this number in CSS). We can even center the columns and choose the width of each column if we know we want to code it this way later:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UXpD9CygaP0gKAm9IdHL2A.png" /></figure><p>From now on this grid will always be visible on the page while designing, but if you try to export it as a .png you won’t see it, don’t worry (I’ll show the export at the end).</p><h3>Step four: Text</h3><p>There are some little secrets that make working with text easier. Let’s start with the navigation bar. Assume you have some menu sections and icons for it. First we grab a text tool and put the text into it, choosing the font and size in the Text section on the right:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HT-_Gu5eHYPIKojZg7lUfg.png" /></figure><p>Now we want to create the NavTextStyle in Text Styles so that I do not have to set it every time I create a navbar.</p><ol><li>Click on the text element (if you are editing text, you want to click outside the workspace and then select the text frame, otherwise you cannot do anything except edit text).</li><li>In the Text Tools, click the icon with the four circles, then click +.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CtsKLUtfSDRJCxySIoiMSg.png" /></figure><p>3. Name your style and click Create Style.</p><p>Now you can click on any text element, then go to the Text tool, click on the same icon with the fourth circle and choose your own style — it will be the same on every element you want. You can do the same with all other styles.</p><p>But with navbar we have some other problems. How to make all the text on the same line with the same margin?</p><ol><li>Select all elements (press Shift and click on each one).</li><li>Go to the right toolbar and at the top you will see the Align tools. Select Align Top or Align Bottom.</li><li>Then go to Auto Layouts and click +, set the gap between elements to 15px (or whatever you want).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v2jrZpQ04D1rlyzPrWXF3A.png" /></figure><p>You can group these elements (Ctrl+G) so that they will always act as one element in the future. Now you can add icons in it, set the size on the icons in the toolbar on the right and set the margin between the text element and the icon just like we did.</p><blockquote><em>Hint with image: You can insert any image you want to the Figma just by drag and drop from any website or Ctrl+C Ctrl+V from your computer. The same goes for copying any element on the page.</em></blockquote><p>For the navbar, you may want to copy some text, or an icon. If you want to copy items more easily, click on it, press Alt and drag it — that’s it. We can even copy and drag the element and save its alignment by pressing Shift along with Alt.</p><h3>Step five: Buttons and Input</h3><p>To create a button or input, select the Rectangle tool and set the radius, stroke (border), and drop shadow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qlWXWtzXbj7k11Mw58E9nQ.png" /></figure><blockquote><em>I think there is a cooler way to do this with components, but I am not a designer and have no idea how to do it.</em></blockquote><p>By the way, when you work with Figma, pay attention to these red lines — they help you to center elements and measure the right gap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sdv6OT7gIzH0-7-x3hhgBQ.png" /></figure><p>I assume these are all the basic elements I use when working with Figma. Everything else is your imagination and creativity. I made this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHIvEJsuUKAqL4FiXKQiqQ.png" /></figure><h3>Step six: Export prototype as PNG</h3><p>This is very easy. Click on the frame, go to the right toolbar, at the bottom you will see the Export section. Choose the format and size (real size or doubled, etc.). Then press the Export button. Make sure you select the whole frame and not just a specific element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMlh5W6gA4IzL54I-cpCRQ.png" /></figure><blockquote>To be sure that all your elements belong to the frame, look to the left. The parent frame is bold. If some of your elements are outside the frame, click and drag them right there:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IS42tYykluj6j1dAFFFamw.png" /></figure><h3>Step seven: Grab styles to your CSS</h3><p>I know there is a way to copy styles from Figma, but I don’t like it much. What I do is copy colors, font sizes, margins, etc. To do this, go to dev mode (click the toggle on the right top corner — green one on a screen). Here you can see all the styles by clicking on the element:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iubuno_EsUoyFFISOsF0CA.png" /></figure><p>This is all you need to make a cool prototype for your project. But there are a lot of interesting thighs and effects that Figma can do. If you want to learn more — there are lots of 1 minute YouTube tutorials. Have fun with Figma and make your projects look great!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e62ac494ab90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step-by-step guide for setting up a Redux stock with toolkit (and Redux thunk)]]></title>
            <link>https://medium.com/@dianagureev/step-by-step-guide-for-setting-up-a-redux-stock-with-toolkit-and-redux-thunk-a401b5cbe48e?source=rss-7e069eb5360d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a401b5cbe48e</guid>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Diana Gureev]]></dc:creator>
            <pubDate>Mon, 27 Nov 2023 17:01:34 GMT</pubDate>
            <atom:updated>2023-11-27T17:01:34.010Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V7rPusS0TXpmHf11s3qAdg.png" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Brett Jordan</a> on <a href="https://unsplash.com/photos/brown-wooden-blocks-on-white-surface-yRDsiNdfNJc?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>If you’ve ever felt stuck trying to set up a Redux store, especially when dealing with async functions, you’re not alone. This guide is designed to be beginner friendly, so you can navigate through the setup process without any hiccups.</p><h3>Step 1: Creating new React App</h3><p>In Terminal:</p><ul><li>npx create-react-app name-app</li><li>cd name-app</li><li>npm i react-redux @reduxjs/toolkit</li></ul><h3>Step 2: Create Your Redux Slice</h3><ul><li>create a folder named “feature” inside the src folder</li><li>create a file named nameSlice.js</li></ul><p>In nameSlice.js:</p><pre>import { createSlice } from &quot;@reduxjs/toolkit&quot;;<br><br>const initState = {<br>    data:[ ]<br>};<br><br>export const nameSlice = createSlice({<br>    name: name,<br>    initialState: initState,<br>    reducers: {<br>        action1: (state, action) =&gt; {<br><br>        },<br>        action2: (state, action)=&gt; {<br>   <br>        },<br>        action3: (state, action)=&gt; {<br>      <br>        },<br>        <br>    }<br>})<br>export const {action1, action2,action3} = nameSlice.actions<br><br>export default nameSlice.reducer<br><br>export const nameState = (state)=&gt; state.name.data</pre><p>After reducers object inside the createSlice:</p><pre>extraReducers(builder){<br>        builder<br>        .addCase(fetchName.pending, (state) =&gt; {<br>            state.status = &quot;loading&quot;;<br>          })<br>        .addCase(fetchName.fulfilled, (state, action)=&gt; {<br>            state.status = &quot;succeeded&quot;;<br>            state.data = action.payload<br>        })<br>        .addCase(fetchName.rejected, (state) =&gt; {<br>            state.status = &quot;rejected&quot;;<br>          })<br>    }</pre><p>*If you are using redux-thunk, include also:</p><pre>import {createAsyncThunk} from &quot;@reduxjs/toolkit&quot;;<br>import axios from &#39;axios&#39;;<br><br>const YOUR_API = &#39;https://url&#39;;<br><br>export const fetchName = createAsyncThunk(&#39;name/fetchName&#39;, async()=&gt;{<br>  const response = await axios.get(YOUR_API)<br>  return response.data<br>})</pre><p>*In case you need to simulate an async function, the previous fetch might look like this:</p><pre>export const nameAsync = createAsyncThunk(&#39;name/nameAsync , async(a)=&gt;{<br>    let res = await new Promise((resolve) =&gt; {<br>        setTimeout(() =&gt; {<br>          resolve (<br>            a+=1<br>          )<br>        }, 1000)<br>    })<br>    return res<br>  })</pre><h3>Step 3: Configure Your Redux Store</h3><ul><li>create a folder named “app” in the src folder</li><li>create file store.js inside app</li></ul><p>Inside store.js:</p><pre>import {configureStore} from &#39;@reduxjs/toolkit&#39;;<br>import nameReducer from &#39;../features/name/nameSlice.js&#39;<br><br>export const store = configureStore(<br>    {<br>        reducer: {<br>            name: nameReducer <br>        }<br>    }<br>)</pre><ul><li>go to the root folder and locate the index.js file</li></ul><p>Inside index.js:</p><pre>import {store} from &quot;./app/store.js&quot;<br>import {Provider} from &#39;react-redux&#39;<br><br>const root = ReactDOM.createRoot(document.getElementById(&#39;root&#39;));<br>root.render(<br>  &lt;React.StrictMode&gt;<br>    &lt;Provider store={store}&gt;<br>    &lt;App /&gt;<br>    &lt;/Provider&gt;<br>  &lt;/React.StrictMode&gt;<br>);</pre><h3>Step 4: Create Your React Component</h3><p>Go back to the features folder and create a Component (or Class), then:</p><pre>import { useSelector, useDispatch } from &quot;react-redux&quot;<br>import { useEffect } from &quot;react&quot; // if need to fetch data when mount the page. <br>import {nameState, action1, action2,action3, fetchName (if redux-thunk)} from &#39;./nameSlice.js&#39;<br><br>const Component = (props) =&gt; {<br>    const list = useSelector(nameState)<br>const dispatch = useDispatch()<br><br><br>return ()<br><br>}<br><br>export default Component</pre><p>Congratulations! You’ve successfully set up your Redux store using the Toolkit and Redux Thunk. This guide is your go-to resource for painless store setup, ensuring a smooth ride through the Redux world. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a401b5cbe48e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HEX-RGB Converter on JavaScript]]></title>
            <link>https://medium.com/@dianagureev/hex-rgb-converter-on-javascript-e6f4daadce5f?source=rss-7e069eb5360d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6f4daadce5f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[converter]]></category>
            <dc:creator><![CDATA[Diana Gureev]]></dc:creator>
            <pubDate>Sat, 11 Nov 2023 13:58:40 GMT</pubDate>
            <atom:updated>2023-11-11T13:58:40.648Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pLlrHDZbJX36rOu1_uOthw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@brizmaker?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Alex</a> on <a href="https://unsplash.com/photos/orange-yellow-and-blue-papers-_ZfLlKxilpw?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p><em>My Google Doc with this article is called “hexRgbConverter”, which shows that I am spending a lot of time with JavaScript this month!</em></p><p>I want to share this HEX to RGB Converter with you as it might be useful for your projects. We are going to create three functions: RGB to HEX, HEX to RGB and a general function to detect which of the two functions we are about to call.</p><blockquote>As always, I would appreciate any feedback on how to make my functions cleaner and easier.</blockquote><p>Start by creating an object with a hexadecimal number system. For an easy understanding, take a look at this picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*gobuU68ZfCynuxmSed2TSQ.png" /></figure><p>That’s what it looks like in my code:</p><pre>const hex = {<br>    &#39;0&#39;: &#39;0&#39;,<br>    &#39;1&#39;: &#39;1&#39;,<br>    &#39;2&#39;: &#39;2&#39;,<br>    &#39;3&#39;: &#39;3&#39;,<br>    &#39;4&#39;: &#39;4&#39;,<br>    &#39;5&#39;: &#39;5&#39;,<br>    &#39;6&#39;: &#39;6&#39;,<br>    &#39;7&#39;: &#39;6&#39;,<br>    &#39;8&#39;: &#39;8&#39;,<br>    &#39;9&#39;: &#39;9&#39;, <br>    &#39;10&#39;: &#39;A&#39;, <br>    &#39;11&#39;: &#39;B&#39;, <br>    &#39;12&#39;: &#39;C&#39;, <br>    &#39;13&#39;: &#39;D&#39;, <br>    &#39;14&#39;: &#39;E&#39;,<br>    &#39;15&#39;: &#39;F&#39;<br>}</pre><p>Time to create a function called “rgbToHex” that takes a string as a parameter:</p><pre>function rgbToHex(rgb){<br>}</pre><p>Inside the function I will split the string into an array and declare a variable for the hex result string. Therefore I will put “#” there.</p><pre>let rgbColor = rgb.split(&#39;, &#39;)<br>let hexResult = &#39;#&#39;</pre><p>Now we know that RGB contains 3 colors, each of which can be from 0 to 255. And HEX also contains three colors, each represented by two letters (or digits).</p><p>Now look at the hexadecimal number system. From 0 to 9, both RGB and HEX are the same, except that HEX has the digit twice. So all we have to do is take an element from RGB and put it twice in HEX — there will be two digits representing a color (RED, GREEN or BLUE accordingly).</p><p>I will go through the loop to check each RGB element in the array. To check if it is only one digit, I retrieve values from my Hexadecimal Number System object as an array of string and check if it includes the element. If so, I simply append that element twice to my hex string:</p><pre>function rgbToHex(rgb){<br>    let rgbColor = rgb.split(&#39;, &#39;)<br>    let hexResult = &#39;#&#39;<br>    let values = Object.values(hex)<br><br>    rgbColor.forEach(element =&gt; {<br>        console.log(element)<br>        if (values.includes(element)){<br>            console.log(element)<br>            hexResult += element + element // &#39;#elementelement&#39;<br> }</pre><p>If values array doesn’t contain the element, it means that there is more than one digit in it. Now to convert it we need simple formula (we use 16 in it because the hexadecimal system is in units of 16: 0–9, A-F).</p><p>For example, we have 255 in RGB. To convert it to HEX we need to divide it by 16, which will give us 15.9375. This will be a number from which we will calculate the first and second character of our HEX color.</p><p><strong>The first character</strong> is easy — we take the whole number with no remainder. This is 15, right?</p><p><strong>For the second character</strong>, we multiply the remainder by 16. This will also give us 15. Now all we have to do is find the letter in our hexadecimal system that represents the number 15. It is F, so we will have FF in our HEX.</p><p>Don’t forget to convert the string to the number for math operations.</p><pre>function rgbToHex(rgb){<br>    let rgbColor = rgb.split(&#39;, &#39;)<br>    let hexResult = &#39;#&#39;<br>    let values = Object.values(hex)<br><br>    rgbColor.forEach(element =&gt; {<br>        console.log(element)<br>        if (values.includes(element)){<br>            console.log(element)<br>            hexResult += element + element<br>        } else {<br>            let number = Number(element)/16;<br>            console.log(number)<br>            let firstDig = String(number).slice(0,2).replace(&#39;.&#39;, &#39;&#39;);<br>            console.log(firstDig)<br>            let secondDig = String(((number - Number(firstDig))*16));<br>            console.log(secondDig)<br>            hexResult += hex[firstDig]<br>            hexResult += hex[secondDig]<br>        }<br>    });<br><br>    console.log(hexResult)<br>}</pre><p>We are done with the first function. In the second function “hexToRgb” we need to rebuild our RGB color in almost the same way.</p><p>As a first step, I will remove the “#” and split the string into an array. And declare an empty array for future RGB.</p><pre>function hexToRgb(hexArr){<br>    let hexArr = hexArr.replace(&#39;#&#39;,&#39;&#39;).split(&#39;&#39;)<br>    let rgbResult = []<br>}</pre><p>Since now I need to convert HEX to RGB I want to switch “key, value” pairs in my hexadecimal number system object, I will use <strong>entries </strong>(it will give use an array of pairs “key, value”), <strong>map </strong>(we will have an array with switch “key, value”) and <strong>fromEntries </strong>to build a switched object.</p><pre>function hexToRgb(hexStr){<br>    let hexArr = hexStr.replace(&#39;#&#39;,&#39;&#39;).split(&#39;&#39;)<br>    let rgbResult = []<br><br>    let rgbObj = Object.entries(hex)<br>    let rgbCheck = Object.fromEntries(rgbObj.map(([key, value]) =&gt; [value, key]))<br>}</pre><p>Now we can loop through hexArr. I will use the “for” loop with i &lt; 3 since we only need to retrieve three colors and inside the function we will always work with two elements.</p><pre>function hexToRgb(hexStr){<br>    let hexArr = hexStr.replace(&#39;#&#39;,&#39;&#39;).split(&#39;&#39;)<br>    let rgbResult = []<br><br>    let rgbObj = Object.entries(hex)<br>    let rgbCheck = Object.fromEntries(rgbObj.map(([key, value]) =&gt; [value, key]))<br>    <br>    for (let i = 0; i &lt; 3; i++) {}<br>}</pre><p>I will start with the first element in hexArr. I want to know if it is a letter or a number because the formula will be a bit different. To do this I will use an “if” statement with the condition “<strong>if (!Number.isNaN(checkEl) === true)</strong>”.</p><pre>function hexToRgb(hexStr){<br>    let hexArr = hexStr.replace(&#39;#&#39;,&#39;&#39;).split(&#39;&#39;)<br>    let rgbResult = []<br><br>    let rgbObj = Object.entries(hex)<br>    let rgbCheck = Object.fromEntries(rgbObj.map(([key, value]) =&gt; [value, key]))<br>    <br>    for (let i = 0; i &lt; 3; i++) {<br>        let checkEl = Number(hexArr[0])<br><br>        if (!Number.isNaN(checkEl) === true){}<br><br>}</pre><p>We know from RGB that if our HEX color consists of two similar digits, it means that the RGB color is only one digit. So I will compare the first element with the second and if they are similar, I will push to the RGB its first color. And then I will remove the first two elements from the hexArr:</p><pre>function hexToRgb(hexStr){<br>    let hexArr = hexStr.replace(&#39;#&#39;,&#39;&#39;).split(&#39;&#39;)<br>    let rgbResult = []<br><br>    let rgbObj = Object.entries(hex)<br>    let rgbCheck = Object.fromEntries(rgbObj.map(([key, value]) =&gt; [value, key]))<br>    <br>    for (let i = 0; i &lt; 3; i++) {<br>        let checkEl = Number(hexArr[0])<br><br>        if (!Number.isNaN(checkEl) === true){<br>            if (hexArr[0] === hexArr[1]){<br>                rgbResult.push(String(hexArr[0]))<br>                hexArr.splice(0,2)<br>            } <br>}</pre><p>What if they are not similar? In this case we need a formula.</p><p>For example, one of our HEX colors is 47. We start with the second digit. Since we know from RGB that the second HEX digit is a remainder of a whole number, and we multiplied it by 16, we will now divide it by 16 to find a real remainder:</p><pre>secondNum = Number(hexArr[1])/16 // 7/16 = 0.4375</pre><p>Since we took the first number in our RGB function without any reminder, we will not even touch it. So we have 4.</p><p>The total number of RGB colors will be the sum of the first number and a reminder, multiplied then by 16:</p><pre>total = (Number(hexArr[0]) + secondNum)*16</pre><p>Thus (4 + 0.4375)*16 = 71. Now we push it to the RGB array and remove those two digits from the hexArr.</p><pre>function hexToRgb(hexStr){<br>    let hexArr = hexStr.replace(&#39;#&#39;,&#39;&#39;).split(&#39;&#39;)<br>    let rgbResult = []<br><br>    let rgbObj = Object.entries(hex)<br>    let rgbCheck = Object.fromEntries(rgbObj.map(([key, value]) =&gt; [value, key]))<br>    <br>    for (let i = 0; i &lt; 3; i++) {<br>        let checkEl = Number(hexArr[0])<br><br>        if (!Number.isNaN(checkEl) === true){<br>            if (hexArr[0] === hexArr[1]){<br>                rgbResult.push(String(hexArr[0]))<br>                hexArr.splice(0,2)<br>            } else{<br>                secondNum = Number(hexArr[1])/16<br>                console.log(secondNum)<br><br>                total = (Number(hexArr[0]) + secondNum)*16<br>                console.log(total)<br><br>                rgbResult.push(String(total))<br>                hexArr.splice(0,2)<br>            }<br>}</pre><p>But what if the condition “ if (!Number.isNaN(checkEl)” gave us false? This means that we are now dealing with letters. Here we need a switched “key:value” object. First we will convert the HEX letter to its numbers and divide the second number by 16 as we did before:</p><pre>firstChar = hexArr[0] //D<br>firstNum = Number(rgbCheck[firstChar]) //13<br>secondChar = hexArr[1] //C<br>secondNum = Number(rgbCheck[secondChar])/16 //0.75</pre><p>Okay, so now all we need to do is sum the first and second numbers and multiply the result by 16:</p><pre>total = (firstNum + secondNum)*16</pre><p>Then push it to rgbResult and remove two elements from hexArr. And we have second function (don’t forget to join the array if you want to show result as string:</p><pre>function hexToRgb(hexStr){<br>    let hexArr = hexStr.replace(&#39;#&#39;,&#39;&#39;).split(&#39;&#39;)<br>    let rgbResult = []<br><br>    let rgbObj = Object.entries(hex)<br>    let rgbCheck = Object.fromEntries(rgbObj.map(([key, value]) =&gt; [value, key]))<br>    <br>    for (let i = 0; i &lt; 3; i++) {<br>        let checkEl = Number(hexArr[0])<br><br>        if (!Number.isNaN(checkEl) === true){<br>            if (hexArr[0] === hexArr[1]){<br>                rgbResult.push(String(hexArr[0]))<br>                hexArr.splice(0,2)<br>            } else{<br>                secondNum = Number(hexArr[1])/16<br>                console.log(secondNum)<br><br>                total = (Number(hexArr[0]) + secondNum)*16<br>                console.log(total)<br><br>                rgbResult.push(String(total))<br>                hexArr.splice(0,2)<br>            }<br>        } else {<br>            firstChar = hexArr[0] //D<br>            firstNum = Number(rgbCheck[firstChar]) //13<br>            secondChar = hexArr[1] //C<br>            secondNum = Number(rgbCheck[secondChar])/16 //0.75<br>            <br>            total = (firstNum + secondNum)*16<br>            rgbResult.push(String(total))<br>            hexArr.splice(0,2)<br>        }<br>    }<br><br>    console.log(rgbResult.join(&#39;, &#39;))<br>}</pre><p>The third function is quite simple. We need to identify whether string is in hex or RGB and call the needed function. My suggestion is to do this through the condition “if (str.includes(‘#’))”, because if its true, then it is a HEX, right?</p><pre>function convert(str){<br>    if (str.includes(&#39;#&#39;)){<br>        hexToRgb(str)<br>    } else {<br>        rgbToHex(str)<br>    }<br>}<br><br>convert(&#39;#FF5466&#39;)</pre><p>That’s it! Hope it helps!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6f4daadce5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My short Python Journey into DNA Mutation Simulator]]></title>
            <link>https://medium.com/@dianagureev/my-short-python-journey-into-dna-mutation-simulator-6b1ce78fae61?source=rss-7e069eb5360d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b1ce78fae61</guid>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Diana Gureev]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 12:12:25 GMT</pubDate>
            <atom:updated>2023-09-27T12:12:25.289Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of coding, every project holds the potential for growth and discovery. In this article, I’d like to take you through the process of working on one of my educational mini-projects. I just feel that by trying to explain what I am doing, I am starting to understand it in a deeper way. Also, there is a chance that you might be able to find a way for me to improve the code, so why not?)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zQh_YR42LchKC2fAmi6Zsg.png" /><figcaption>Photo by <a href="https://unsplash.com/@lanirudhreddy?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">ANIRUDH</a> on <a href="https://unsplash.com/photos/tiTzBRnr7PY?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>My task is:</p><blockquote>Build a DNA object. DNA is composed of chromosomes which itself is composed of Genes.</blockquote><blockquote>A Gene is a single value 0 or 1, it can mutate (flip). A Chromosome is a series of 10 Genes. It also can mutate, meaning a random number of genes can randomly flip (1/2 chance to flip).</blockquote><blockquote>A DNA is a series of 10 chromosomes, and it can also mutate the same way Chromosomes can mutate.</blockquote><blockquote>Implement these classes as you see fit. Create a new class called Organism that accepts a DNA object and an environment parameter that sets the probability for its DNA to mutate. Instantiate Organism and let it mutate until it gets to a DNA which is only made of 1s.</blockquote><blockquote>Then stop and record the number of generations (iterations) it took.</blockquote><p>I decided to do this with separate classes, although I was considering doing it with subclasses, still not sure.</p><p>I made four classes: Gene, Chromosome, DNA and Organism. The basic one is Gene and also the simplest one.</p><p>Since genes can only be 1 or 0 and can mutate with a 1/2 chance of flipping, I decided to make a list and randomly select them each time with the random module. So I had to import this module first:</p><pre>from random import choice, sample, randrange</pre><p>Then I define the mutation list (mut) and a special function that reverses the gen value.</p><pre>class Gene:<br>    mut = [0, 1] #At first I thought that it could be a boolean, but then I found that it was easier to iterate with real integers<br>    def __init__(self):<br>        self.gene = choice(self.mut)<br>    def flip(self):<br>        if self.gene == 1: #I need this piece of code to make it easier for the programme to mutate. Otherwise we can spend a lot, like a lot, of time waiting for mutation<br>            return<br>        self.gene = choice(self.mut)<br><br><br>    def __str__(self):<br>        return f&#39;{self.gene}&#39; #I need this method in my check_dna function to check DNA by gene value and not by object</pre><p>Now I need to create a chromosome containing 10 genes with random values.</p><p>So when I initiate a Chromosome object it will randomly generate 10 genes and give me the list of 10 Gene objects.</p><pre>class Chromosome:<br>    def __init__(self):<br>        self.list_gen = []<br>        for one_gene in range(10):<br>            one_gene = Gene()<br>            self.list_gen.append(one_gene)</pre><p>Then, since we need Chromosome to mutate from time to time, I define a mutate function:</p><pre> def mutate(self):<br>        if self.list_gen == [1,1,1,1,1,1,1,1,1,1]: #I also need this piece of code to make it easier for the programme to ideally mutate<br>            return #meaning - return nothing, otherwise:<br>        mutate_genes = sample(self.list_gen, randrange(10))#Here I use the sample random method + randrange, which allows me to select a random number of genes within a chromosome<br>        for gen in mutate_genes:<br>            gen.flip()</pre><p>The DNA class works quite similarly to the Chromosome class:</p><pre>class DNA:<br>    def __init__(self):<br><br><br>        self.list_chro = [] #When initiating DNA, we want 10 chromosomes. So I made a loop to create a list of chromosomes<br>        for one_chro in range(10):<br>            one_chro = Chromosome()<br>            self.list_chro.append(one_chro)<br><br><br>    def mutate(self):<br>        mutate_chro_list = sample(self.list_chro, randrange(10))#Again, I use a random sample method to select the chromosomes to mutate<br>        for chro in mutate_chro_list:<br>            chro.mutate() #And call a mutate function on the Chromosome object</pre><p>In my first iteration of the code, I thought that after mutating, I needed to replace the original objects in self.list_gen with new mutated objects. Then I realised that this is not necessary because we are only changing a value in the object, not the object itself. So we can keep the self.list_gen and the values will change anyway.</p><p>Now we have everything we need to create an organism:</p><pre>class Organism:<br>    def __init__(self, mutate = False): #Organism needs to know whether it should mutate or not, by default it shouldn&#39;t.<br>        self.dna = DNA()<br>        self.mut = mutate<br>   <br>        if self.mut == True: #If it should, we call mutate function while initiating an object to make an ideal organism<br>            self.mutate()</pre><p>To do the mutation, we need to check whether our DNA is already ideal or not. So I created a function to do that:</p><pre>def org_dna(self):<br>        string_gen = &#39;&#39; #I decided to save the result as a string, so I can check if we still have zero in the string<br>        for chromosome in self.dna.list_chro: #I iterate through list of chromosomes in DNA<br>            for gen in chromosome.list_gen:#I iterate through list of genes in each chromosome<br>                string_gen += gen.__str__() #With the dunder method string I can now get the string of genes in each DNA<br>        return string_gen<br><br><br>    def check_dna(self):<br>        if &#39;0&#39; in self.org_dna(): #In string_gen<br>            return False<br>        else:<br>            return True</pre><p>Now we can define a while loop to consistently mutate the chromosomes and genes to achieve an ideal result:</p><pre> def mutate(self):<br>        count = 0 #I need this variable to record the number of generations<br>        while self.check_dna() == False: #While DNA has zero in the string<br>            count +=1 #Record<br>            self.dna.mutate()#Mutate<br>            self.check_dna()#Then we check DNA again<br>        else:<br>            print(count)#At the moment I have an ideal DNA, I print the number of iteration. </pre><p>Now we can check that everything is working:</p><pre>organism1 = Organism(True)<br>organism2 = Organism(False)<br>print(organism1.org_dna())<br>print(organism2.org_dna())</pre><p>The output that I have received:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q_zVpmA0ZL_sjl7M" /></figure><p><strong><em>First string -</em></strong><em> times of iteration</em></p><p><strong><em>Second one -</em></strong><em> Ideal DNA, which mutated 41 times</em></p><p><strong><em>Third one</em></strong><em> - General DNA with False mutation argument</em></p><p>I really appreciate any feedback that can help me improve the result. So please feel free to leave your opinion below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b1ce78fae61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Power of Google Search: how to use a search to the max]]></title>
            <link>https://medium.com/@dianagureev/unlocking-the-power-of-google-search-how-to-use-a-search-to-the-max-11d5006a7552?source=rss-7e069eb5360d------2</link>
            <guid isPermaLink="false">https://medium.com/p/11d5006a7552</guid>
            <category><![CDATA[google-search]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Diana Gureev]]></dc:creator>
            <pubDate>Sun, 17 Sep 2023 10:55:46 GMT</pubDate>
            <atom:updated>2023-09-27T08:01:01.746Z</atom:updated>
            <content:encoded><![CDATA[<p>As a brand new developer, I have to Google a lot. It helps us juniors not to ask basic questions and to see the scope of the task, right? But not everyone is aware that Google Search has a lot of special features that help us make the results more precise. These features are called “Google search operators”, and we don’t need any extra tools — we just type them into the search bar with our query and that’s it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YakQGq31mYcr0VgR3tYiVw.png" /><figcaption>Photo by <a href="https://unsplash.com/@arty_nyc?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Arthur Osipyan</a> on <a href="https://unsplash.com/photos/5OyvN4Yx46E?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>My name is Diana. A few months ago I decided to change my career path from project management in SaaS (SEO analytics tools) to full stack development. It’s challenging, but from my background I know some hacks that help me make things easier.</p><blockquote>I don’t know if you’ve ever thought about it, but a search engine is just an algorithm. The keywords (every word in our search query) are compared with Google’s search database (called the index). So it doesn’t really understand your intention. It tries to guess. You can play with your query to force it find exactly what you want. You can even get results catered to a specific country.</blockquote><p>I will now illustrate several key operators that significantly enhance the efficiency of my daily web searches. I will be presenting a total of five essential operators, along with an additional one more just for fun. I hope it helps you too, one day!</p><h3>Clarifying the request: Quotation Marks “”</h3><p>This is the operator I use most often. It allows us to fix the phrase or word in the search query. For example, if we type in a long request like “how to add additional value to the key in dictionary python”, we get the following results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jKcudyvuBw80uOvlNEbmMg.png" /><figcaption>Search results before using Quotation Marks</figcaption></figure><p>But it is not at all what I want, because the <strong>update() method</strong> will change the value of the key. I need to fix the phrase by adding quotes in “additional value”, and here’s what I get now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*daDlXsXRrJ9kiPb_IjPrGQ.png" /><figcaption>Search results after using Quotation Marks</figcaption></figure><blockquote><em>By the way, I found the answer: we can actually append the value with the same method we use for lists, strings and so on, all because of the inheritance. If the dictionary has a list in it, it means we can use any list method with this list, like dict[key].append(value). This may be nothing new to some of you, but for me it was, and I was very happy to find it.</em></blockquote><p>So now if you have mixed results and want to specify your answer — use the “” operator.</p><h3>Broadening Search Horizons: OR with Parentheses ()</h3><p>I use it when I need to find two almost similar things and I don’t want to waste time on two queries. For example, I know that I want to update the dictionary and the set (dump example, but just as an example). So I can write “(dictionary OR set) how to update python”. Now I have all the results on my search page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_q5K7QNXY9NQhW-hFD_D5w.png" /><figcaption>Using OR operator</figcaption></figure><p>And you can also use Quotation Marks along with others if you need.</p><h3>Excluding Irrelevant Results: Minus «-»</h3><p>The minus operator allows us to exclude some words and phrases from the search results.</p><p>For example, if we see that something is not relevant to what you are looking for. Imagine you need help writing a function to check your password, but you don’t want to use regex (regular expression). If we search “how to check the password in python”, we get this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZ7d1PyCHKZhh0N_wyNBWA.png" /><figcaption>SERP without minus operator</figcaption></figure><p>But with regex excluded, we will get a different result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JWcPAAjhwKAdS0VF08Sxpg.png" /><figcaption>Minus operator usage</figcaption></figure><p>So use it when you see that there are several approaches and you know which one is best for you right now.</p><h3>Getting Targeted Results: «Intitle:»</h3><p>In general this operator comes from SEO, but it helps me to find good articles that specify on what I want. For example, if I search for “how to add new value to dict key”, I can have some articles like: all about dict in python, how to add key:value pairs in python, etc. That’s because Google searches in all the content types it has: page titles, main content, img’s alts, videos, etc. But I don’t need that. So I can search specifically in page titles to make sure it is exactly what I want.</p><p>To do this, I write my search query right after intitle: operator: “intitle: “new value for dict key” python”.</p><blockquote>We can also use this when looking for a job. Try writing a query like “[job title] intitle: “work for us”” or something similar.</blockquote><p><strong>Note:</strong> If the query is too detailed, it might not work with the quotes operator.</p><h3>Using Site-Specific Search: «Site:»</h3><p>This operator helps me search within a specific site. Say you are obsessed with Medium, so you only want to read the articles from here. Use “query site:medium.com”. Instead of “query”, type in your topic. You will get something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uo9y561xg1Jza9M0jSVDsw.png" /><figcaption>Site-Specific operator</figcaption></figure><p>I love using it for information queries when I want to find something to read. We can also make it even cooler by adding the “after:YYYY” operator, like [python dictionaries after:2022], which helps us find the latest publications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2CSAxfGGFcIuIqYddCpZqg.png" /><figcaption>Results with date operator</figcaption></figure><h3>Additionally</h3><h4>Controlling Results Number: Num = xx</h4><p>With this operator we can control the number of the result. I never use it, but if you really hate that 1000 pages in Google Search you never see, put the max amount up to 100 😀</p><p>These are my TOP operators, but there are many more. If you want to dive deeper into this subject, please refer to this article on Moz.com: <a href="https://moz.com/learn/seo/search-operators">Ultimate Guide to Google Search Operators and Parameters</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11d5006a7552" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>