<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jagadish Ranasthala</title>
    <description>The latest articles on DEV Community by Jagadish Ranasthala (@ranasthala-dev).</description>
    <link>https://dev.to/ranasthala-dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3157293%2F92de117a-41a7-4031-ae5b-1f05d52598b7.png</url>
      <title>DEV Community: Jagadish Ranasthala</title>
      <link>https://dev.to/ranasthala-dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ranasthala-dev"/>
    <language>en</language>
    <item>
      <title>Let’s Get Life Easy: Secure JSON/CSV Conversions Without Uploading Data</title>
      <dc:creator>Jagadish Ranasthala</dc:creator>
      <pubDate>Wed, 21 May 2025 17:09:26 +0000</pubDate>
      <link>https://dev.to/ranasthala-dev/lets-get-life-easy-secure-jsoncsv-conversions-without-uploading-data-4cl9</link>
      <guid>https://dev.to/ranasthala-dev/lets-get-life-easy-secure-jsoncsv-conversions-without-uploading-data-4cl9</guid>
      <description>&lt;p&gt;Have you ever faced difficulty with conversions from JSON to CSV or CSV to JSON?&lt;/p&gt;

&lt;p&gt;JSON makes a programmer’s life easy, while CSV makes an accountant’s life easy. But when we’re working across teams or systems, we often need both formats.&lt;/p&gt;

&lt;p&gt;That’s where conversions come in.&lt;/p&gt;

&lt;p&gt;Sure, there are plenty of online tools available. It’s convenient — but let’s pause for a second...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What about data privacy?&lt;/strong&gt;&lt;br&gt;
Is it really okay to upload sensitive or internal data to a public tool?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We’re developers — &lt;strong&gt;we can solve this ourselves&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And the best part?&lt;br&gt;
You don’t need a full-blown runtime, environment, or server.&lt;br&gt;
Just a simple &lt;strong&gt;Bash script + PHP&lt;/strong&gt; (hey, PHP isn’t dead yet 😉).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JSON to CSV&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -r '$data = json_decode(file_get_contents("path/input.json"), true);$fp = fopen("output.csv", "w");fputcsv($fp, array_keys($data[0]));foreach ($data as $row) fputcsv($fp, $row);fclose($fp);'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSV to JSON&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -r '$csv = array_map("str_getcsv", file("path/input.csv"));$headers = array_shift($csv);$data = array_map(fn($row) =&amp;gt; array_combine($headers, $row), $csv);file_put_contents("path/output.json", json_encode($data, JSON_PRETTY_PRINT));'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;➕Bonus: XLSX to JSON&lt;/strong&gt;&lt;br&gt;
We can’t convert .xlsx directly to JSON — first, we convert it to CSV using LibreOffice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;libreoffice --headless --convert-to csv input.xlsx --outdir . &amp;amp;&amp;amp; mv input.csv desired_name.csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then reuse the CSV to JSON step above.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>php</category>
    </item>
    <item>
      <title>Laravel Worker with Supervisor: Automate Your Way Out of Manual Madness</title>
      <dc:creator>Jagadish Ranasthala</dc:creator>
      <pubDate>Wed, 14 May 2025 17:54:56 +0000</pubDate>
      <link>https://dev.to/ranasthala-dev/laravel-worker-with-supervisor-automate-your-way-out-of-manual-madness-2phd</link>
      <guid>https://dev.to/ranasthala-dev/laravel-worker-with-supervisor-automate-your-way-out-of-manual-madness-2phd</guid>
      <description>&lt;p&gt;Hey folks,&lt;br&gt;
We all know that most mind-numbing, repetitive tasks can be offloaded to automation - and nothing beats the good old cron job when it comes to routine work&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case in Point: Employee Attendance&lt;/strong&gt;&lt;br&gt;
Let's say you need to log employee attendance daily.&lt;br&gt;
The old-school way might look like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;HR (shouting from her cabin)&lt;/strong&gt;: "Alex…"&lt;br&gt;
&lt;strong&gt;Alex&lt;/strong&gt;: "Present, ma'am!"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwvqmx4srko7yzs0pu5i5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwvqmx4srko7yzs0pu5i5.png" alt="hr" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Charming, but inefficient.&lt;br&gt;
With Laravel (our multitasking superhero) and Supervisor, we can automate this cleanly - especially if you're using biometric devices and APIs (thanks to APIs for making data fetching simple).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-by-Step: Automating Laravel Scheduler with Supervisor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Install Supervisor&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
sudo apt install supervisor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check if Supervisor is installed properly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;supervisord --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Create a Laravel Worker Config&lt;/strong&gt;&lt;br&gt;
Edit or create the Supervisor config file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/supervisor/conf.d/laravel-worker.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste the following config (update paths and user as per your setup):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[program:laravel-scheduler]
directory=/home/ranasthala-dev/team-app
command=bash -c 'php /var/www/html/artisan schedule:run 2&amp;gt;&amp;amp;1 | grep -v "No scheduled commands"'
autostart=true
autorestart=true
user=jagadish
redirect_stderr=true
stdout_logfile=/home/ranasthala-dev/team-app/storage/logs/laravel-scheduler.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Start and Manage the Worker&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo supervisorctl reread       # Detect new programs
sudo supervisorctl update       # Apply new config
sudo supervisorctl start laravel-scheduler
sudo supervisorctl status       # Check if it's running
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Check Log Output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tail -f /home/ranasthala-dev/team-app/storage/logs/laravel-scheduler.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will show you real-time logs from your scheduler.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why This Rocks&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No need to rely on crontab entries.&lt;/li&gt;
&lt;li&gt;Your scheduler runs as a background process and restarts automatically if it fails.&lt;/li&gt;
&lt;li&gt;Logs give you a direct view into task execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, the next time your HR shouts across the office, let Laravel and Supervisor answer back with a silent but efficient "present!"&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
