<?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 Ujjwal Bhardwaj on Medium]]></title>
        <description><![CDATA[Stories by Ujjwal Bhardwaj on Medium]]></description>
        <link>https://medium.com/@ujjwalbhardwaj?source=rss-7457b8a48ce2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ME1a9kBVfWtqI9-f.</url>
            <title>Stories by Ujjwal Bhardwaj on Medium</title>
            <link>https://medium.com/@ujjwalbhardwaj?source=rss-7457b8a48ce2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 00:48:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ujjwalbhardwaj/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[Disable Local Hive CLI Execution in Amazon EMR]]></title>
            <link>https://medium.com/@ujjwalbhardwaj/disable-local-hive-cli-execution-in-amazon-emr-97b1a0b7abb0?source=rss-7457b8a48ce2------2</link>
            <guid isPermaLink="false">https://medium.com/p/97b1a0b7abb0</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[emr]]></category>
            <dc:creator><![CDATA[Ujjwal Bhardwaj]]></dc:creator>
            <pubDate>Tue, 06 Nov 2018 13:56:27 GMT</pubDate>
            <atom:updated>2018-11-06T13:57:15.903Z</atom:updated>
            <content:encoded><![CDATA[<p>Hive is an open-source, data warehouse, and analytics package that runs on top of a Hadoop cluster. Hive scripts use a SQL-like language called Hive QL (query language) that abstracts programming models and supports typical data warehouse interactions.</p><p>Hive implementations need a metastore service, where it stores metadata. It is implemented using tables in a relational database. By default, Hive records metastore information in a MySQL database on the master node’s file system and provides clients (including Hive) access to this information using the metastore service API.</p><p>The two popular hive clients used are Hive CLI and Beeline. Beeline connects to Hive Metastore via Hive Server 2 which integrates authentication and authorisation mechanisms whereas there is no such mechanism associated with Hive CLI. Thus, for security reasons, it is always recommended that connections via Hive CLI are disabled.</p><p>To disable direct connections to hive metastore and allow connections to metastore only via hive-server2, one can log in to the master node of the EMR Cluster and</p><ol><li>Disable hive-cli by modifying <em>/etc/hive/conf/hive-env.sh</em> to include the below lines:</li></ol><pre>if [ &quot;$SERVICE&quot; = &quot;cli&quot; ]; then<br>   echo &quot;Sorry! hive-shell is disabled for security purpose.&quot;<br>   exit 1<br> fi</pre><p>2. Disable hive-cli by renaming/removing hive binary from <em>/usr/bin</em>.</p><p>3. Create an alias for ‘hive’ in order to redirect it to beeline. This can be done using the following command</p><pre>alias hive=&quot;beeline&quot;</pre><p>The first solution can be automated during the creation of the cluster by creating a step.</p><h4>Automation of the first solution during the creation of the cluster by creating a step.</h4><p>We can submit work to Amazon EMR clusters using steps. Each step is a unit of work that contains instructions to manipulate data for processing by software installed on the cluster. We can also run a command line script at any time during step processing in your cluster. These scripts can be executed by provisioning either the command-runner.jar or the script-runner.jar. The command-runner.jar package executes commands inputted as arguments to the step whereas the script-runner.jar executes a script stored in an S3 bucket with its URL provided as an argument to the step.</p><p>You can use the following script to automate the first solution of this problem.</p><pre>#!/bin/bash<br><br>echo -e &quot;\nif [ \&quot;\$SERVICE\&quot; = \&quot;cli\&quot; ]; then echo \&quot;Hive CLI is disabled for security purpose\&quot;; exit 1; fi&quot; | sudo tee --append /etc/hive/conf/hive-env.sh &gt; /dev/null</pre><p>The aforementioned echo command can also be added as an argument to the command-runner.jar step.</p><p>To add a step to run the script using the AWS CLI, we can execute the following command</p><pre>aws emr create-cluster --name &quot;Test cluster&quot; –-release-label emr-5.15.0 --applications Name=Hive Name=Pig --use-default-roles --ec2-attributes KeyName=myKey --instance-type m4.large --instance-count 3 --steps Type=CUSTOM_JAR,Name=CustomJAR,ActionOnFailure=CONTINUE,Jar=s3://region.elasticmapreduce/libs/script-runner/script-runner.jar,Args=[&quot;s3://mybucket/script-path/my_script.sh”]</pre><p>Original Post: <a href="https://ujjwalbhardwaj.me/post/disable-local-hive-cli-execution-in-amazon-emr">https://ujjwalbhardwaj.me/post/disable-local-hive-cli-execution-in-amazon-emr</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97b1a0b7abb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Store and Retrieve Image From MongoDB Using PHP]]></title>
            <link>https://medium.com/@ujjwalbhardwaj/store-and-retrieve-image-from-mongodb-using-php-daa7a8a6e48d?source=rss-7457b8a48ce2------2</link>
            <guid isPermaLink="false">https://medium.com/p/daa7a8a6e48d</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Ujjwal Bhardwaj]]></dc:creator>
            <pubDate>Sat, 26 Nov 2016 20:45:34 GMT</pubDate>
            <atom:updated>2016-11-26T20:45:34.715Z</atom:updated>
            <content:encoded><![CDATA[<p>While I was working on my project <a href="https://github.com/imujjwal96/prelimQuiz">prelimQuiz</a>, I got stuck at a serious problem. In a quiz, the quizmaster might need to add images along with the question, I had to add this feature, and for that, the uploaded image has to be stored and retrieved from the database. Since it was the first time I was integrating MongoDB with PHP, so I had no command over the predefined helper functions. Adding to my problem was the fact that the extension of MongoDB driver for PHP is now deprecated, and most of the tutorials online were for this legacy driver. After researching for quite some time, I found the solution.</p><p>In my project, this feature is implemented in an Object Oriented format. So, I’ll try to make it as easy to understand as possible for me. The following pieces of code may have some reminiscences of the projects.</p><h3>PREREQUISITES:</h3><ul><li>PHP &gt;= 5.6</li><li>MongoDB</li><li><a href="https://pecl.php.net/package/mongodb/1.1.8/windows">MongoDB PHP Driver</a></li></ul><h3>Uploading Image</h3><pre>&lt;form method=&quot;POST&quot; action=&quot;&quot; enctype=&quot;multipart/form-data&quot;&gt;<br>  ...................<br>  &lt;input type=&quot;file&quot; name=&quot;cover&quot; &gt;<br>  ..................<br>  &lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;<br>&lt;/form&gt;</pre><h3>Retrieving image from $_FILE and storing it in a database collection</h3><pre>if (isset($_FILES[&quot;cover&quot;])) {<br>  $questionCover = $_FILES[&quot;question_cover&quot;];</pre><pre>  // Establish MongoDB Connection<br>  $connection = new MongoDB\Client(&quot;mongodb://localhost:27017&quot;);<br>  $databaseMongo = $connection-&gt;selectDatabase(Config::get(&#39;DB_NAME&#39;));</pre><pre>  $questions = $databaseMongo-&gt;selectCollection(&quot;questions&quot;);<br>  $document = array(<br>      &quot;type&quot; =&gt; &quot;MCQ&quot;,<br>      &quot;cover&quot; =&gt; new MongoDB\BSON\Binary(file_get_contents($questionCover[&quot;tmp_name&quot;]), MongoDB\BSON\Binary::TYPE_GENERIC),<br>  );<br>  if ($questions-&gt;insertOne($document)) {<br>      return true;<br>  }<br>  return false;</pre><h3>Retrieve image from database</h3><pre>// Establish MongoDB Connection<br>$connection = new MongoDB\Client(&quot;mongodb://localhost:27017&quot;);<br>$databaseMongo = $connection-&gt;selectDatabase(Config::get(&#39;DB_NAME&#39;));</pre><pre>$questions = $databaseMongo-&gt;selectCollection(&quot;questions&quot;);</pre><pre>$questionsArray = $questions-&gt;find()-&gt;toArray();</pre><pre>foreach ($questionsArray as $question) {<br>        if ($level == 1) {<br>            $myQuestion = $question;<br>            break;<br>        }<br> }</pre><h3>Displaying image (as HTML image tag)</h3><pre>&lt;img src=&quot;data:jpeg;base64,&lt;?=base64_encode($myQuestion-&gt;cover-&gt;getData())?&gt; &quot; /&gt;</pre><h3>Displaying image (Alternative)</h3><pre>header(&#39;Content-Type: image/png&#39;);<br>imagepng(imagecreatefromstring($myQuestion-&gt;cover-&gt;getData()));</pre><p>You can see the code in action @<a href="https://github.com/imujjwal96/prelimQuiz">prelimQuiz</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=daa7a8a6e48d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Hacktoberfest Experience]]></title>
            <link>https://medium.com/@ujjwalbhardwaj/my-hacktoberfest-experience-4d0dac175194?source=rss-7457b8a48ce2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d0dac175194</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[digitalocean]]></category>
            <category><![CDATA[hacktoberfest]]></category>
            <dc:creator><![CDATA[Ujjwal Bhardwaj]]></dc:creator>
            <pubDate>Fri, 25 Nov 2016 08:11:10 GMT</pubDate>
            <atom:updated>2016-11-25T08:11:10.780Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://hacktoberfest.digitalocean.com/">Hacktoberfest</a>, a joint venture of <a href="https://www.digitalocean.com/">DigitalOcean</a> and <a href="https://github.com/">Github</a>, is a month-long celebration of open source software. Introduced to promote the open source, Hacktoberfest invites maintainers of open source projects to develop their software and guide would-be contributors towards issues to help move the project forward. It also stands out as a great platform for young and new developers like me to gain some knowledge and get the opportunity to give back to both projects we like and ones we’ve discovered during the span of the fest.</p><p>DigitalOcean introduced Hacktoberfest in 2015, and I only got acquainted with it in September’2016 when they released the notification on this year’s Hacktoberfest. In one way or another, it gave me a purpose on working towards enhancing my skills and I was sure it would turn out to be both fun and lucrative for me.</p><p>The thing I like the most about Hacktoberfest is that, apart from giving contributors to various projects free T-shirts, it provides a huge platform to developers to promote their projects. It provides great help to those who are stuck with their projects or have a lot of flaws in them.</p><p>This Hacktoberfest, I got the chance to play the role of both a contributor and a maintainer, and it was a great learning experience for me, not much as a contributor but as a developer/maintainer of projects.</p><p>When the fest started, I was keen to contribute to many of the projects I liked (<a href="https://github.com/phpmyadmin/phpmyadmin">phpMyAdmin</a>, <a href="https://github.com/owncloud">ownCloud</a>, etc.). I looked through their source code and in the first few hours of perusing them, I realized I was not competent enough to be able to contribute to them. It left me disheartened, and so I stopped looking for projects to contribute to but instead resumed working on my project, <a href="https://github.com/imujjwal96/prelimQuiz">prelimQuiz</a>. While developing it, I got stuck at a point. I wanted my app secured, and for that, it needed to be protected from CSRF. I knew the concept of CSRF and had applied it in some of my projects built with NodeJS, but I could not think of a way to implement it in my app for which I chose PHP to be the back-end language. So I raised an issue and within the following 48 hours the project received a pull request.</p><p>Unfortunately, due to certain design issues, I did not merge the pull request. That pull request certainly gave me an idea on how to solve the problem. Moreover, it triggered a thought in my mind to keep raising issues and labeling them with “Hacktoberfest” to attract developers to my repository so that they could help me enhance my code, and also improve me as a developer. After that, I started receiving many PRs which helped me develop my project at a relatively fast pace.</p><p>It would be wise to mention here that although it was very helpful for my project, it made me quite lazy. I started raising issues on many fixes and patches which would not have required a lot of my time. Due to this laziness, I have not yet rectified those issues that did not get much attention, or their pull requests did not follow the specifications.</p><p>Even with particular turbulence present, things were going fine for me as the developer of a project, but I needed that T-shirt, and for that, I had to contribute to someone else’s projects. Fortunately, a friend of mine contacted me regarding a <a href="https://github.com/imujjwal96/PurpleWall">project</a> idea he wanted to work on and required someone to work on its back-end. So I grabbed this opportunity as fast as I could and for my greed (Yes, I said it) I told him to create a public repository for it and gave 4+ successful PR to his project which made me eligible for the T-shirt.</p><p>The T-shirt has not yet arrived, but I hope that it would be worth the struggle.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d0dac175194" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>