<?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 Sandali Disara on Medium]]></title>
        <description><![CDATA[Stories by Sandali Disara on Medium]]></description>
        <link>https://medium.com/@sandalidissanayake123?source=rss-b642b3ce9b3d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4SPAN1-vMwF5v6VHcBwYjQ.jpeg</url>
            <title>Stories by Sandali Disara on Medium</title>
            <link>https://medium.com/@sandalidissanayake123?source=rss-b642b3ce9b3d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:37:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sandalidissanayake123/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[Automatically Run Scripts on Raspberry Pi]]></title>
            <link>https://medium.com/@sandalidissanayake123/automatically-run-scripts-in-raspberry-pi-1da89d300dd4?source=rss-b642b3ce9b3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1da89d300dd4</guid>
            <dc:creator><![CDATA[Sandali Disara]]></dc:creator>
            <pubDate>Sat, 11 May 2024 13:29:20 GMT</pubDate>
            <atom:updated>2024-05-11T13:44:50.622Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*7NHccPrUn1r8kC9UK0iz2g.jpeg" /></figure><p>After establishing the continuous integration (CI) pipeline between the RPi and the GitHub Repo, you might be wondering how to automatically run the ‘./run.sh’ file that comes with the self-hosted runner that is installed in the Raspberry Pi. Don’t worry I got you covered. Follow this step-by-step guide to do the following.</p><p><strong><em>Pre-requisites</em></strong></p><p>Prepare the repository and Raspberry Pi device to run GitHub actions in a self-hosted way.</p><p>Refer the article to get started with connecting the device and repository to GitHub actions. (<a href="https://pabluc.medium.com/raspberrypi-github-actions-ci-cd-1dc098b4c7d3">RaspberryPi+Github Actions+CI/CD. A small practice to spend my free time | by Pabluc | Medium</a>)</p><p>When the python script is pushed to the repository, the synchronized code will be maintained both in the Raspberry Pi and GitHub repository.</p><p>Here, the ./run.sh locates inside the actions-runner folder has to be run manually to start the runner in the RPi.</p><p>Now we will follow the steps required to automatically run this ./run.sh file when the RPi is tuened on.</p><ol><li><strong>Create a service file and bring it into system level</strong></li></ol><p>Create a file in any location for now because we will be taking this file to the system-level later. Give the file extension as ‘service’ (e.g.- fileName.service). As the ‘ExecStart’ attribute give the location of the runner file and as the ‘User’ attribute give the username of the Raspberry Pi.</p><pre>[Unit]<br>Description=Github CI<br><br>[Service]<br>User=hydrosmart<br>ExecStart=/home/hydrosmart/HydroRasp/actions-runner/run.sh<br><br>[Install]<br>WantedBy=multi-user.target</pre><p>This service file created in the user level has to be brought to the system level for it to be executed at the booting up stage.</p><pre>sudo cp hydrosmart-ci.service /etc/systemd/system/</pre><p>After copying the file, you may need to reload the systemd manager configuration to recognize the changes. You can do this by running:</p><pre>sudo systemctl daemon-reload</pre><p>Locate to the system level and the list (ls) the files and directories in system to check if the created service file is there. (go to the root of the Raspberry Pi and then type in the below command to navigate)</p><pre>cd etc/systemd/system</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*Wwr5QCB0y5ygBCIaAhpOkA.png" /></figure><p>2. <strong>Give Executable permission to the created file</strong></p><p>The created service file will not have executable permissions when it is first created. Without doing this, you will not have permission to start your service.</p><pre>chmod +x hydrosmart-ci.service</pre><p>3. <strong>Start the created service</strong></p><p>Now that you have added your executable service file to the system level, start the service to start the runner file located.</p><pre>sudo systemctl start hydrosmart-ci.service</pre><p>Check the status of the service file and see whether the runner file is up and running.</p><pre>sudo systemctl status hydrosmart-ci.service</pre><p>Now that you have everything set up, the runner file (./run) will automatically run when the Raspberry Pi is Boot up.</p><p><em>Proofreader: </em><a href="https://www.linkedin.com/in/lakshanthad">https://www.linkedin.com/in/lakshanthad</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1da89d300dd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Connectivity Between Raspberry Pi and Firebase]]></title>
            <link>https://medium.com/@sandalidissanayake123/create-connectivity-between-raspberry-pi-and-firebase-c1a82edb3b68?source=rss-b642b3ce9b3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1a82edb3b68</guid>
            <dc:creator><![CDATA[Sandali Disara]]></dc:creator>
            <pubDate>Wed, 27 Mar 2024 12:24:50 GMT</pubDate>
            <atom:updated>2024-03-27T12:24:50.416Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*eHCb1GB7IFzvRJEQ7ACxSQ.png" /></figure><p><strong><em>Task to be done</em></strong></p><p>There is a python script written to generate a random number between 10 and 30 every 20 seconds. This generated number is stored in firebase, with the value generated and the time it was generated. (Field names — timestamp, value).</p><p><strong><em>Pre-requisites</em></strong></p><p>Prepare the repository and Raspberry Pi device to run GitHub actions in a self-hosted way.</p><p>Refer the article to get started with connecting the device and repository to GitHub actions. (<a href="https://pabluc.medium.com/raspberrypi-github-actions-ci-cd-1dc098b4c7d3">RaspberryPi+Github Actions+CI/CD. A small practice to spend my free time | by Pabluc | Medium</a>)</p><p>When the python script is pushed to the repository, the synchronized code will be maintained both in the Raspberry Pi and GitHub repository.</p><ol><li>Install the Firebase Admin SDK for Python using pip</li></ol><pre>pip install firebase-admin</pre><p>2. Generate the private key from Firebase project.</p><ul><li>Create new project or select an existing project.</li><li>Navigate to <em>project settings</em> &gt; <em>service accounts</em> tab.</li><li>Generate a new private key and download the JSON file containing your service account credentials. Keep this file secure.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B959qbXDWKU9vpYET2RXEg.png" /><figcaption>Get private key from Firebase</figcaption></figure><p>3. Store the JSON file downloaded in the repository inside a suitable folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*la1g3y3GUMiDyf-bBar5oA.png" /></figure><p>4. Call the firebase service key JSON file in the python script to access the firebase datastore and store the necessary data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*H0cSuSnTiQu_8WwggMwsRA.png" /><figcaption>value and time are stored in ‘random_numbers’ collection in firestore database</figcaption></figure><p>5. Add the Firebase folder to .gitignore to secure the private key without exposing it to public through the repository.</p><p>6. Connect GitHub Repository with Firebase</p><ul><li>Go to your GitHub repository.</li><li>Navigate to <em>secrets and variables</em> &gt; <em>Actions</em> &gt; <em>New repository secret</em></li><li>Name the secret (e.g. FIREBASE_SERVICE_ACCOUNT_KEY) and copy the content in the JSON file as the value of the key.</li><li>Click <em>Add secret</em> to save the key.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KbFf9Nt5RO867U8ZesOr5w.png" /><figcaption>Add firebase private key to repository secret</figcaption></figure><p>7. Modify the GitHub Actions YAML file.</p><p>The service account key JSON file will not be pushed to the repository as the <em>Firebase</em> folder is included in .gitignore file. Therefore, when the changes are synchronized to the Raspberry Pi through GitHub actions, the python script will not be able to locate the JSON file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*tR-d0EkpsEk7Sm3z6fbwBg.png" /></figure><p>Therefore, in workflow YAML file we use the secret key to access the Firebase credentials securely. In the RaspberryPi, a Firebase folder and a file to store the key will be created. Content of the secret key stored are copied to the JSON file created in RPi.</p><p>8. Commit the changes to GitHub repository and push the changes.</p><p>9. Run the randomNum.py file in RaspberryPi and see the data being stored in firestore database.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1a82edb3b68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Send an Email with ReactJS without a Backend]]></title>
            <link>https://medium.com/@sandalidissanayake123/send-an-email-with-reactjs-without-a-backend-fa23c133e145?source=rss-b642b3ce9b3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa23c133e145</guid>
            <category><![CDATA[send-email]]></category>
            <category><![CDATA[emailjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nobackend]]></category>
            <dc:creator><![CDATA[Sandali Disara]]></dc:creator>
            <pubDate>Tue, 09 May 2023 10:23:44 GMT</pubDate>
            <atom:updated>2023-05-09T11:16:21.235Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xfmDu9XIQFcmrKvHONdvdg.png" /></figure><p>A simple ReactJS component is made to send an email without any Backend. Here ‘EmailJS’ is used for this purpose.</p><p>First create a React Application by running the command</p><pre>npx create-react-app my-app-name</pre><p>Create a <em>Components </em>folder inside the <em>src </em>folder and create a file <em>ContactForm.js. </em>We will also style this using CSS. Create a file <em>form.css</em> inside <em>Components</em> folder. Import the CSS file on top of the <em>ContactForm</em> component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*KjrJP43MgLV8XDLvV3f6hA.png" /><figcaption><em>ContactForm.js</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*iYQ4WcnBMAYeW7Bh7C_04g.png" /><figcaption>form.css</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*F3yL9J4UAOGAt6tnbjZ9Vg.png" /><figcaption>form.css</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*PuVfC-4QyYl7W5VoZPR7Rw.png" /><figcaption>form.css</figcaption></figure><p>You can just create a form by identifying the form fields in the <em>ContactForm.js </em>without any CSS to simplify the process.</p><pre>import ContactForm from &quot;./components/contactForm&quot;;<br><br><br>function App() {<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;ContactForm/&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p>Import the component created inside App.js</p><p>Run the react application on your browser by typing the below command. The form will be displayed as below.</p><pre>&gt; npm start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lUM3qSZuShbJcgBfmxZWQ.png" /></figure><p>Head over to the EmailJS website <a href="https://www.emailjs.com/">https://www.emailjs.com/</a> and login or create an account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*vAxRCxpPE3mHkywgzklTTw.png" /></figure><p>Add a new Email Service. In order to make it simple, it’s recommended to use Gmail as the email service. Click on <em>Connect Account</em> to connect to your email account. A connection success message should appear after connecting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2XCpNQHm_VR_mfWe3-LJWQ.png" /></figure><p>Create a template by clicking<em> Email Templates</em> from the left menu. Click <em>Create New Template</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*QRL30aY1qV24Sq6X_-xHDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_k9VE8vUOxpzAv2Qw6BS9g.png" /></figure><p>The corresponding ‘name’ attribute values used in input tags in <em>ContactForm.js</em> are used here as the values inside the curly brackets. After saving the template, head over to <em>Docs -&gt; Examples -&gt; React</em> to connect the react code with EmailJS.</p><p>Install @emailjs/browser to your react application to connect to EmailJS</p><pre>&gt; npm install @emailjs/browser</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*XCfgkEC81BOmj-cab_i1sA.png" /><figcaption>ContactForm.js</figcaption></figure><p>import useRef from react library and emailjs from the package we installed earlier. <em>useRef()</em> is pointed to the form by giving the variable name ‘<em>form</em>’ in the form tag. <em>sendEmail </em>function handles the operations that happen after submitting the form.</p><p>Replace the string values mentioned above with these values mentioned below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uuA1nWSDkKaH4pXF4p94OQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJLyvNPpeaPKy77NMfPQEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EGCFUDCYUqU-D0eSRxo3pA.png" /></figure><p>Fill the form from your browser after running the application and submit to send the email to the recipient’s email address you mentioned.</p><p><a href="https://github.com/SandaliDisara/Frontend-Email-ReactJS">SandaliDisara/Frontend-Email-ReactJS (github.com)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa23c133e145" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>