<?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:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[blog.tanay.co]]></title><description><![CDATA[Thoughts, stories and ideas.]]></description><link>https://blog.tanay.co/</link><image><url>https://blog.tanay.co/favicon.png</url><title>blog.tanay.co</title><link>https://blog.tanay.co/</link></image><generator>Ghost 1.21</generator><lastBuildDate>Wed, 08 Apr 2026 08:01:28 GMT</lastBuildDate><atom:link href="https://blog.tanay.co/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Making my IR based RGB strip smart - EspHome on Home Assistant.]]></title><description><![CDATA[Imagine getting up late at night in a pitch dark room, and you start hitting your toenails, Or you just start walking, and "the house" turns on a guiding light for you to follow. Read more on how I transformed my cheap LED strip to IoT enabled and assistant controlled.]]></description><link>https://blog.tanay.co/making-your-led-smart-with-esphome-and-home-assistant/</link><guid isPermaLink="false">5f7201307f4a01056a7950f9</guid><category><![CDATA[home-assistant]]></category><category><![CDATA[tips-n-tricks]]></category><category><![CDATA[how-to]]></category><category><![CDATA[esphome]]></category><category><![CDATA[led]]></category><category><![CDATA[smart home]]></category><category><![CDATA[rgb]]></category><category><![CDATA[google assistant]]></category><category><![CDATA[smart light]]></category><category><![CDATA[ir]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Sat, 31 Oct 2020 04:00:00 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2020/11/ha_smart_led_jumbo.jpg" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2020/11/ha_smart_led_jumbo.jpg" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."><p>I had a basic RGB strip that came with an IR blaster. Good one, working flawlessly for over a year now. I can control it via the remote and occasionally I would even forget it can spit out colors other than violet.</p>
<p>A week after I started playing with <a href="https://blog.tanay.co/home-automation-and-why-home-assistant">Home Assistant</a>, I decided I want to hook it up to this little brain. Imagine getting up late at night in a pitch dark room, and you start hitting your toenails; Or you just start walking, and &quot;the house&quot; turns on a guiding light for you to follow. With <a href="https://amzn.to/36dCJV3">smart bulbs</a> and <a href="https://amzn.to/3n6YLPx">strips</a> it is straight forward to just link into HA with community maintained integrations.</p>
<p>But what I had was a pair of dirt-cheap analog strips, already attached to my bedroom windowpane since I moved into the new house. So I started to look for ways to use the existing setup in my room with minimal changes.</p>
<p><img src="https://blog.tanay.co/content/images/2020/11/ha_smart_led_controller.webp" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."></p>
<h2 id="huntingwaystocontrolthestrip">Hunting ways to control the strip.</h2>
<p>The first step was to get to know about the different methods I can use to control this RGB strip. After a few google searches and DIY videos, I was left with these three options -</p>
<h3 id="1generich801rgbwcontroller">1. Generic H801 RGBW controller</h3>
<p>The <a href="https://amzn.to/3cIkkRw">H801 controller</a> is one of the easily available LED controllers with separate RGB channels. Another benefit of using this one will be ease of integration into ESPHome. They even have a cookbook tutorial for it.</p>
<ul>
<li>H801 RGBW LED controller<br>
<a href="https://esphome.io/cookbook/h801.html">https://esphome.io/cookbook/h801.html</a></li>
</ul>
<h3 id="2pwmdedicateanespmodule">2. PWM - dedicate an esp module.</h3>
<p>PWM is an acronym for <a href="https://en.wikipedia.org/wiki/Pulse-width_modulation">Pulse Width Modulation</a>. If you know how analog strip works - the three channels can be supplied with different voltage and thereby controlling the intensity of Red, Green, and Blue which in turn produces different colors. There are <a href="https://www.instructables.com/id/IOT-ESP-8266-Nodemcu-Controlling-RGB-LED-Strip-Ove/">existing tutorials</a> on how to wire things up in <a href="https://amzn.to/3csWh96">node MCU</a>. One can combine this up with <a href="https://esphome.io/components/light/rgbw.html">RGBW light component</a> from Esphome to easily have a fully integrated working solution. This would also allow you to utilize a whole bunch of <a href="https://esphome.io/components/light/index.html#light-effects">effects</a> without doing any extra work.</p>
<ul>
<li><a href="https://www.instructables.com/id/IOT-ESP-8266-Nodemcu-Controlling-RGB-LED-Strip-Ove">https://www.instructables.com/id/IOT-ESP-8266-Nodemcu-Controlling-RGB-LED-Strip-Ove</a></li>
<li><a href="https://esphome.io/components/light/rgbw.html">https://esphome.io/components/light/rgbw.html</a></li>
</ul>
<h3 id="3mimictheirremoteviaesphome">3. Mimic the IR remote via ESPHome.</h3>
<p>Like I said, I had everything already set up and working via the remote. What if I can mimic to hit the red button when I set it red from Home assistant? Theoretically, that should just work!</p>
<p>Folks have already made few tutorials on how to set up an IR led acting as a remote with node MCU.</p>
<ol>
<li><a href="https://www.instructables.com/id/ESP8266-RGB-LED-STRIP-WIFI-Control-NODEMCU-As-a-IR/">https://www.instructables.com/id/ESP8266-RGB-LED-STRIP-WIFI-Control-NODEMCU-As-a-IR/</a></li>
<li><a href="https://www.instructables.com/id/WiFi-LED-Strip-Controller-Based-on-ESP-8266/">https://www.instructables.com/id/WiFi-LED-Strip-Controller-Based-on-ESP-8266/</a></li>
</ol>
<p>I just needed to figure out how to get this working in Home Assistant.</p>
<h2 id="puttingthingstogether">Putting things together.</h2>
<p>Hardware hints from the first tutorial above - One IR LED with a simple resistor? Yes, I can do that :)</p>
<p><img src="https://blog.tanay.co/content/images/2020/11/ha_smart_led_wiring.webp" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."></p>
<p>The next step was to use this IR blaster to send some test signals. ESPHome has a very handy component for this very specific task - <a href="https://esphome.io/components/remote_transmitter.html">Remote Transmitter</a>. But before we dive in there, it would be good to know how the basic protocols work. The Wikipedia page on <a href="https://en.wikipedia.org/wiki/Consumer_IR">Consumer IR Protocols</a> do not have much info, but I found a little article briefing just about the same.</p>
<p><a href="https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol">https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol</a></p>
<p>This is just NEC. If the above link is broken, please search for basic IR <a href="http://google.com/?q=ir+nec+protocol">NEC codes</a>. Most RGB IR transmitters available in the market follow similar NEC protocols. There are other protocols and few vendor-specific ones too, but we do not need to worry about that for this project.</p>
<p>Good that the folks over ESPHome have already made this simple. Thanks to the articles above, I already knew the <em>command I needed</em> to send; and from the docs I knew - <em>how to send</em>. Combining both, I had a working example to switch on and switch off the strip.</p>
<pre><code>  esphome:
    name: node_one
    platform: ESP8266
    board: nodemcuv2

  wifi:
    ssid: &quot;***&quot;
    password: &quot;********&quot;

  # Enable logging
  logger:

  captive_portal:

  remote_transmitter:
    pin: GPIO2
    carrier_duty_percent: 50%
    
  switch:
    - platform: template
      name: strip_on
      turn_on_action:
        - remote_transmitter.transmit_nec:
            address: 0xF7
            command: 0xC03F
    
    - platform: template
      name: strip_off
      turn_on_action:
        - remote_transmitter.transmit_nec:
            address: 0xF7
            command: 0x40BF

</code></pre>
<p>Once this is sorted, I moved on to the <a href="https://esphome.io/components/light/custom.html">custom light component</a> to see if I can seamlessly create a light entity. The idea was to create a component that would act as a light interface to Home Assistant. Any commands like <code>ON</code>, <code>OFF</code>, <code>Switching colors</code> etc would be translated and mapped to the proper buttons on the remote.</p>
<p><img src="https://blog.tanay.co/content/images/2020/11/ha_smart_led_color_map.webp" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."></p>
<h3 id="mappingcolorstoabutton">Mapping colors to a button.</h3>
<p>There are tons of available color palettes in the HA dashboard, while my remote and driver can recognize only 12 out of those! With some <a href="https://stackoverflow.com/a/1847112">help</a>, I deduced a way to map a given color value to the nearest shade available on the remote.</p>
<h3 id="mappingbrightness">Mapping brightness.</h3>
<p>The only buttons available were to increase and decrease brightness. So even if Home Assistant was providing us with brightness info, it was of no use on its own. Instead, if there is a change in brightness, we can use this delta to determine if we need to send Brightness <code>UP</code> or <code>DOWN</code> command.</p>
<p>Proceeding on with this assumption, I created a custom component to set desirable traits and make a handle available to Home Assistant. On receiving commands, it translated them to their remote counterparts and the driver behaves just like if someone had pressed the remote.</p>
<blockquote>
<p>RGBStripLight<br>
<a href="https://github.com/tanaykumarbera/homeassistant-config/blob/master/esphome/rgbstriplight.h">homeassistant-config/esphome/rgbstriplight.h</a></p>
</blockquote>
<p><img src="https://blog.tanay.co/content/images/2020/11/ha_smart_dir_struct.webp" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."></p>
<p>Copy and paste the file in Esphome config root. Once there, update your test node to import and create light from this custom component.</p>
<pre><code>remote_transmitter:
    id: esp_transmitter
    pin:
        number: D8
    carrier_duty_percent: 50%
light:
    - platform: custom
      lambda: |-
            auto led_strip = new RGBStripLight(id(esp_transmitter));
            App.register_component(led_strip);
            return {led_strip};
      lights:
            - name: &quot;Window Strip Light&quot;
            default_transition_length: 0s
</code></pre>
<p>Upload and head over to your Home Assistant entities dashboard to configure this newly added light. Try some actions and see if it responds.</p>
<div class="f-group">
<p><img src="https://blog.tanay.co/content/images/2020/11/ha_smart_led_panel.webp" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."></p>
<p><img src="https://blog.tanay.co/content/images/2020/11/ha_smart_led_google_control_knob.webp" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."></p>
<p><img src="https://blog.tanay.co/content/images/2020/11/ha_smart_led_google_control_pallets.webp" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."></p>
<p><img src="https://blog.tanay.co/content/images/2020/11/ha_smart_led_demo.webp" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."></p>
</div>
<p>I also have an integration with Google Assistant. Hence I can easily switch the strips by reaching out to my assistant on the phone or smart speakers.</p>
<p><img src="https://blog.tanay.co/content/images/2020/09/ha_rgb_strip.webp" alt="Making my IR based RGB strip smart - EspHome on Home Assistant."></p>
<h3 id="consreversefeedback">Cons. Reverse feedback?</h3>
<p>I can still use the remote to control the same strip independent of Home Assistant. If I use it to say change the color or turn it off, my HA dashboard would not reflect the state change. This is a current limitation of this approach, but I am okay to live with it 🐷.</p>
<p>If this is something that bothers you, you may choose to go with the PWM solution I posted above. On top of that, if you would like to retain your IR remote support, ESPHome has a <a href="https://esphome.io/components/remote_receiver.html">Remote receiver</a> component as well.</p>
<h2 id="wrapup">Wrap up</h2>
<p>It's been only a few months now, and I have already written about my <a href="https://blog.tanay.co/home-automation-and-why-home-assistant">onboarding</a> experience with Home Assistant. Being a hobbyist myself, I like to customize a lot of things to cater to my needs. And I can definitely back up the level of flexibility Home Assistant and integrations like EspHome is providing here. Looking forward to more of such tweaks in the future. Follow me on <a href="https://twitter.com/tanaykumarbera">@twitter</a> to get latest updates.</p>
<p>Thanks for reading. Have a nice day 🤘</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://esphome.io/cookbook/h801.html">https://esphome.io/cookbook/h801.html</a></li>
<li><a href="https://www.instructables.com/id/IOT-ESP-8266-Nodemcu-Controlling-RGB-LED-Strip-Ove">https://www.instructables.com/id/IOT-ESP-8266-Nodemcu-Controlling-RGB-LED-Strip-Ove</a></li>
<li><a href="https://esphome.io/components/light/rgbw.html">https://esphome.io/components/light/rgbw.html</a></li>
<li><a href="https://www.instructables.com/id/ESP8266-RGB-LED-STRIP-WIFI-Control-NODEMCU-As-a-IR/">https://www.instructables.com/id/ESP8266-RGB-LED-STRIP-WIFI-Control-NODEMCU-As-a-IR/</a></li>
<li><a href="https://www.instructables.com/id/WiFi-LED-Strip-Controller-Based-on-ESP-8266/">https://www.instructables.com/id/WiFi-LED-Strip-Controller-Based-on-ESP-8266/</a></li>
<li><a href="https://esphome.io/components/remote_transmitter.html">https://esphome.io/components/remote_transmitter.html</a></li>
<li><a href="https://esphome.io/components/light/custom.html">https://esphome.io/components/light/custom.html</a></li>
</ul>
</div>]]></content:encoded></item><item><title><![CDATA[Home automation and why Home Assistant?]]></title><description><![CDATA[The best thing about getting onboarded to Home Assistant in 2020 is that it has already gone through criticism for the past 7 years. All those reviews have yielded a product so fine that there is integration for everything.]]></description><link>https://blog.tanay.co/home-automation-and-why-home-assistant/</link><guid isPermaLink="false">5f5dddfa7f4a01056a7950c8</guid><category><![CDATA[home-assistant]]></category><category><![CDATA[personal-experiences]]></category><category><![CDATA[product-reviews]]></category><category><![CDATA[tips-n-tricks]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Sat, 19 Sep 2020 13:34:57 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2020/09/home_assistant_overview.jpg" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2020/09/home_assistant_overview.jpg" alt="Home automation and why Home Assistant?"><p>The COVID quarantine came with its terms. Everyone is stuck at home 24 hours; tired, frustrated, easily fatigued with daily chores. Mine is no different. Eventually, I decided to invest myself into some new domains.  I started with very basic ESP modules to set up some IP cameras, and motion sensors around the house. Even I went and hooked them up with platforms like <a href="https://github.com/ccrisan/motioneye">Motion Eye</a> to have a working alert system. All of these came with an intense hunt for how-to and DIY tutorials and things just worked.</p>
<p>Not to mention the bugs, false trigger, and hell lot of instability. The try, adapt and the re-flash cycle was too tiresome. That's when I started looking out for ad hoc solutions. To my surprise, the community around Home automation is no joke. There are much open-source community maintained platforms -</p>
<ul>
<li><a href="https://developer.android.com/things">Android Things</a></li>
<li><a href="https://www.domoticz.com/">Domoticz</a></li>
<li><a href="http://www.homegenie.it/">HomeGenie</a></li>
<li><a href="https://www.home-assistant.io">Home Assistant</a></li>
<li><a href="https://www.openhab.org">OpenHab</a></li>
</ul>
<p>But don't take my word. Go, have your own research and then settle on something which suits your need. All of them have some pros and cons which I am not going into. After considering all options and devices at my end, I went and choose to go with <strong>Home Assistant</strong> - for ease of installation, integration support, and dashboard customizability. To boast a little, this is how my dashboard looks with few files of <code>YAML</code>.</p>
<div class="f-group">
<p><img src="https://blog.tanay.co/content/images/2020/09/ha_dasboard_01.webp" alt="Home automation and why Home Assistant?"></p>
<p><img src="https://blog.tanay.co/content/images/2020/09/ha_dasboard_02.webp" alt="Home automation and why Home Assistant?"></p>
<p><img src="https://blog.tanay.co/content/images/2020/09/ha_dasboard_03.webp" alt="Home automation and why Home Assistant?"></p>
<p><img src="https://blog.tanay.co/content/images/2020/09/ha_dasboard_04.webp" alt="Home automation and why Home Assistant?"></p>
</div>
<p>The best thing about getting onboarded to Home Assistant in 2020 is that it has already gone through criticism for the past seven years. All those reviews have yielded a product so fine that most of your daily needs would have some readymade integration to it. If not, you can spend some time and create your own. Like, I had one of those cheap <a href="https://amzn.to/3kwOxFY">rgb led strip</a> which came with an IR blaster. And also I have had purchased some <a href="https://amzn.to/3csWh96">ESP 8266</a> modules earlier for some other pet projects. Combine them and voila! you have your own generic IR blaster, which seamlessly integrates to the Home Assistant ecosystem. You can control it from anywhere in the world. Heck, throw in some <a href="https://www.home-assistant.io/integrations/google_assistant/">extra hours</a> and it's available in your google home now ❤️</p>
<p><img src="https://blog.tanay.co/content/images/2020/09/ha_rgb_strip.webp" alt="Home automation and why Home Assistant?"></p>
<p>I saved around 2000 INR (~ 25 USD) by utilizing what was at hand. For comparison, here is an <a href="https://amzn.to/2FToSIW">equivalent one on amazon.in</a>. Also, no need to remove the old strip. If you have worked on one, you would know how difficult it would be to.<br>
Now I can control it either by IR remote, my cool HA dashboard, or just shout -</p>
<blockquote>
<p>&quot;Okay google, turn my window led to red!&quot;</p>
</blockquote>
<h1 id="andallthegoodnesscangomobile">And, all the goodness can go mobile.</h1>
<p><a href="https://www.home-assistant.io/lovelace/">Lovelace</a> - the default dashboard of Home Assistant is built on responsive principles. All the cards align themselves based on how much space is available. But why go with the web, when you can just have their app. The official <a href="https://apps.apple.com/us/app/home-assistant/id1099568401">iOS</a> and <a href="https://play.google.com/store/apps/details?id=io.homeassistant.companion.android">Android</a> apps are already available.</p>
<p><img src="https://blog.tanay.co/content/images/2020/09/ha_dasboard_mobile.webp" alt="Home automation and why Home Assistant?"></p>
<p>They come with some extra benefits like presence detection, geo-location-based automation, and the best - push notification! With some simple scripts, I built an automation to push notification on my device whenever my backyard sensor picks up a motion. Cool, isn't it?</p>
<h1 id="raspberryatitsheart">Raspberry at it's heart.</h1>
<p>Okay, so I knew what to do after playing with it for few days on my desktop. But I needed something which can be always on as well as power-efficient. I had a beagle board, but that was not powerful enough to run the whole suite. Finally, after going through the open forums, and community adoption ratio, I settled with a <a href="https://amzn.to/3cyBcdv">Raspberry Pi 4</a>. Also, wrapped up this cutie with a <a href="https://amzn.to/36ohUqf">transparent case</a> and a fan for active cooling.</p>
<p>Pi 4 is one of the officially supported stacks. Also if you are comfortable in Linux, you can go with <a href="https://www.home-assistant.io/docs/installation/">supervised install</a>. That will allow you to retain your access to the host system if you have other things in mind 😉</p>
<h1 id="risewithnodered">Rise with Node Red</h1>
<p>Writing YAML and custom c++ code is fine, but no match to Node-Red. With simple drag and drop, you can achieve complex reactions to almost any events happening within your home assistance.</p>
<p>For eg, here is a simple flow to announce on your Google Home speaker - that your battery is running low.</p>
<p><img src="https://blog.tanay.co/content/images/2020/09/ha_node_red_phone_reminder.webp" alt="Home automation and why Home Assistant?"></p>
<p>Or, some complex flow to turn on / off lights, when a motion is detected. Additionally, I have a variable to control this automation from my home assistant dashboard.</p>
<p><img src="https://blog.tanay.co/content/images/2020/09/ha_node_red_backyard_automation.webp" alt="Home automation and why Home Assistant?"></p>
<p>Be it controlling your devices, turning off the television when no one's around - the possibilities are endless. You can implement anything that you want. I have seen the community building complex automation and reminders once you get how services work in Home assistant. I would be leaving a few resources to read more if you are interested.</p>
<p>Overall, I found out HA to be the one-stop solution for everything smart in our house to communicate and behave. It's like a little <a href="https://en.wikipedia.org/wiki/J.A.R.V.I.S.">jarvis</a> in there, controlling your dumb home. Not there yet, but hey better than reaching out to the wall socket every time.</p>
<p>Github - <a href="https://github.com/tanaykumarbera/homeassistant-config">@tanaykumarbera/homeassistant-config</a></p>
<p>I have opened up my configs to anyone who would like to have a peek into mine. Also I am planning few follow up blogs on few custom components. Follow me on <a href="https://twitter.com/tanaykumarbera">@twitter</a> to get latest updates.</p>
<p><img src="https://blog.tanay.co/content/images/2020/09/cheers.gif" alt="Home automation and why Home Assistant?"></p>
<p>Thanks! Few references that helped me -</p>
<ul>
<li><a href="https://www.home-assistant.io">https://www.home-assistant.io</a></li>
<li><a href="https://www.awesome-ha.com">https://www.awesome-ha.com</a></li>
<li><a href="https://github.com/kalkih/mini-graph-card">https://github.com/kalkih/mini-graph-card</a></li>
<li><a href="https://github.com/kalkih/mini-media-player">https://github.com/kalkih/mini-media-player</a></li>
<li><a href="https://www.juanmtech.com/category/home-assistant/">https://www.juanmtech.com/category/home-assistant/</a></li>
<li><a href="https://youtu.be/SuoSXVqjyfc">https://youtu.be/SuoSXVqjyfc</a></li>
<li><a href="https://www.home-assistant.io/integrations/google_assistant/">https://www.home-assistant.io/integrations/google_assistant/</a></li>
</ul>
</div>]]></content:encoded></item><item><title><![CDATA[Access local devices without DDNS. Expose your little world!]]></title><description><![CDATA[DDNS is awesome until you get to know your ISP does not give you a dedicated IP address. Read more about how DDNS works here.]]></description><link>https://blog.tanay.co/access-local-devices-without-ddns/</link><guid isPermaLink="false">5f5cc00d7f4a01056a7950bc</guid><category><![CDATA[how-to]]></category><category><![CDATA[ddns]]></category><category><![CDATA[home-assistant]]></category><category><![CDATA[https]]></category><category><![CDATA[tips-n-tricks]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Fri, 10 Jul 2020 12:34:00 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2020/09/reverse_proxy_ddns_vs_ssh.jpg" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2020/09/reverse_proxy_ddns_vs_ssh.jpg" alt="Access local devices without DDNS. Expose your little world!"><p>So you built a little site, have a media center, or some home automation that you want to expose to our little internet and came across something called DDNS? Most of the routers available today support DDNS inherently, and there are tons of free service providers to choose from. You might even have successfully set it up only to figure out that it won't work when you are trying to access it in a network outside of your Internet Service Provider (ISP).</p>
<blockquote>
<p>DDNS is awesome until you get to know your ISP does not give you a dedicated IP address. Read more about how DDNS works <a href="https://www.lifewire.com/definition-of-dynamic-dns-816294">here</a></p>
</blockquote>
<h1 id="ddnsdoesnotworkeverytime">DDNS does not work every time</h1>
<p>In a country like India, often Internet Service providers go with IP sharing to minimize their operating costs. You can actually search <a href="http://google.com/?q=whats+my+ip">your public IP</a> online. But the catch is - your friend Joe might be seeing the same IP if you guys are using the same service provider. Your ISP might own a pool of IPs which it uses to connect to &quot;The Internet&quot;. They can lease you one on a temporary basis. Or might even just act as a router to sit in between you, Joe, and other subscribers and the Internet. In either of these cases, it does not means anything to a normal user. They make a network request and get a response. It starts bothering people who want to revert this process - like trying to connect your home router from the outside world.</p>
<p>With a dedicated IP, this is straight forward. You know if your public IP is <code>10.23.12.43</code>, you need to connect to the same address to get hold of your gateway (in this case your home router). You can configure a simple port forward to redirect traffic to your laptop or any device in your home network.</p>
<p>With dynamic ip allocation, it isn't the case anymore. The public IP you see, is resolving to your ISP. It would not direct to your router anymore. Thankfully there are services like <a href="https://ngrok.com">Ngrok</a> and <a href="https://pagekite.net">PageKite</a> which allows you to quickly spin up a service to access local resources. With some alteration to internal proxies, you can easily achieve a static domain to local machine routing. I will let you try these out and see if it works for you.</p>
<h1 id="howaboutsomethingmorerobust">How about something more robust?</h1>
<p>The next solution we have requires you to have a server on the Internet. It gives you total control over how you want to reach your local machine. I am using a free EC2 cluster with a static ip to achieve this, but once you get the hang of it - it's up to you how do you want to set it up.</p>
<p>You will need ssh access to this server.</p>
<p>We will make use of <a href="https://www.howtogeek.com/428413/what-is-reverse-ssh-tunneling-and-how-to-use-it">ssh remote port forwarding</a> and nginx proxy to achieve this. The whole template can be shortened in -</p>
<p><img src="https://blog.tanay.co/content/images/2020/09/reverse_ssh_command.png" alt="Access local devices without DDNS. Expose your little world!"></p>
<p><code>ssh -R 8444:localhost:3000 user@yourserver</code></p>
<p>This sets up a reverse port forwarding to your local machine. Any traffic coming to your remote server at <code>PORT 8444</code> will now be forwarded to <code>PORT 3000</code> of your local machine.</p>
<p><img src="https://blog.tanay.co/content/images/2020/09/reverse_ssh_tunnel.png" alt="Access local devices without DDNS. Expose your little world!"></p>
<p>Now you have a tunnel up. Great! But how do you access <code>8444</code>? Just exposing a random port on your sweet domain might not be something you would want to do. You would end up with something like <code>http://yourserver.com:8444</code>. Not very elegant right?</p>
<p>That is where we might use nginx or a choice of your server which can support a reverse proxy. Caddy is popular as well. It filters out any traffic coming to a specific domain and forwards it internally to <code>PORT 8444</code>; which in turn would be tunneled to your local node at <code>PORT 3000</code>. Just like that!</p>
<p>A sample nginx config would look like -</p>
<pre><code>
    server {

        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name your.domain.co;
        ssl_certificate /etc/ssl/../certificate_chain.crt;
        ssl_certificate_key /etc/ssl/../certificate_private.key;

        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://127.0.0.1:8444;
            proxy_redirect off;
        }
    }

</code></pre>
<p><img src="https://blog.tanay.co/content/images/2020/09/reverse_ssh_client_access.png" alt="Access local devices without DDNS. Expose your little world!"></p>
<p>Awesome! Your local website which was hosted and only accessible from <code>//localhost:3000</code>, can now be accessed from anywhere in the world. Just hit a browser with <code>https://your.domain.co</code> and voilla 🙌</p>
<h1 id="furtherautomateadedicatednode">Further, automate a dedicated node</h1>
<p>We were able to reach our node from an external network. But in case you are like me who might want to host something which can live forever, you may want to automate this process of port forwarding on your local node. I have switched to a combination of <code>autossh</code> and <code>crontab</code>. You may choose any task scheduler.</p>
<p>I have a simple script to check an existing tunnel. If no tunnel or not responding - create a new one. Otherwise, do nothing. I choose to run this at an interval of 15 minutes.</p>
<pre><code>
    # sample script, please tailor as per need.
    # hi@tanay.co
    # &lt;configname&gt; is the ssh host config.
    # $COMMAND is the command used to create the reverse ssh tunnel.

    REMOTE_PORT=8444
    LOCAL_PORT=3000

    FILEPATH=&quot;logs/auto/tunnel_status.log&quot;
    if [ ! -f &quot;$FILEPATH&quot; ]; then
       mkdir -p &quot;$FILEPATH&quot;
       rm -r &quot;$FILEPATH&quot;
    fi

    log &quot;Starting tunnel up if not started&quot;

    COMMAND=&quot;env AUTOSSH_GATETIME=0 autossh -f -M 12092 -N -R $REMOTE_PORT:localhost:$LOCAL_PORT &lt;configname&gt; &amp;&quot;

    # Is the tunnel up? Perform two tests:

    # 1. Check for relevant process ($COMMAND)
    pgrep -f -x &quot;.*ssh.*$REMOTE_PORT:localhost:$LOCAL_PORT.*&quot; &gt; /dev/null 2&gt;&amp;1 || $COMMAND

    # 2. Test tunnel by looking at &quot;netstat&quot; output on $REMOTE_HOST
    ssh &lt;configname&gt; netstat -an | egrep &quot;tcp.*:$REMOTE_PORT.*LISTEN&quot; &gt; /dev/null 2&gt;&amp;1
    if [ $? -ne 0 ] ; then
       log &quot;Found existing one [$?] .. Restarting.&quot;
       pkill -f -x &quot;$COMMAND&quot;
       $COMMAND
    else
       log &quot;Server returned $?. Doing nothing.&quot;
    fi
    log &quot;Tunnel up completed&quot;
    dash

</code></pre>
<p>Few references that helped me refine this idea -</p>
<ol>
<li><a href="https://www.tunnelsup.com/raspberry-pi-phoning-home-using-a-reverse-remote-ssh-tunnel/">https://www.tunnelsup.com/raspberry-pi-phoning-home-using-a-reverse-remote-ssh-tunnel/</a></li>
<li><a href="https://stackoverflow.com/a/1998356">https://stackoverflow.com/a/1998356</a></li>
<li><a href="https://handyman.dulare.com/ssh-tunneling-with-autossh/">https://handyman.dulare.com/ssh-tunneling-with-autossh/</a></li>
</ol>
<p>Thanks for dropping by, Have a nice day ✌️</p>
</div>]]></content:encoded></item><item><title><![CDATA[Take control of Info dialogs on Android Studio]]></title><description><![CDATA[How to resize Info dialogs on Android Studio?  Wondering how to shrink sometimes annoying, but mostly helpful documentation dialogs? Follow here.]]></description><link>https://blog.tanay.co/resize-info-dialogs-on-android-studio/</link><guid isPermaLink="false">5e8c0c4cc5497a056b72b714</guid><category><![CDATA[tips-n-tricks]]></category><category><![CDATA[android-studio]]></category><category><![CDATA[android-development]]></category><category><![CDATA[how-to]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Sun, 18 Nov 2018 05:14:00 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2020/04/header-as-info-resize.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2020/04/header-as-info-resize.png" alt="Take control of Info dialogs on Android Studio"><p>Heya,</p>
<p>So this was completely unexpected, and I stumbled upon it by hitting wrong keys. It never occured to me that we can resize the dialogs in case we running short on space.</p>
<p><img src="https://blog.tanay.co/content/images/2020/04/as-info-resize.gif" alt="Take control of Info dialogs on Android Studio"></p>
<p>Simply hit <code>Cmd + Shit + Right Arrow</code> to expand<br>
or <code>Cmd + Shift + Left Arrow</code> to shrink the dialog in width.</p>
<p>You can also <code>Cmd + Shift + Up arrow</code> and <code>Cmd + Shift + Down arrow</code> to adjust height.</p>
<p>PS. While this is valid on Android Studio, it should also be applicable to other InteliJ IDEs</p>
</div>]]></content:encoded></item><item><title><![CDATA[Fish bone stuck in throat? Just Bong problems!]]></title><description><![CDATA[Feeling a prickling sensation from a fish bone stuck in your throat? This small and yet problematic little buddy might be hard to remove. Learn more about home remedies that I tried and how I was able to pull it out finally.]]></description><link>https://blog.tanay.co/fish-bone-stuck-in-throat-solutions/</link><guid isPermaLink="false">5a393d8397bc0402e7235afb</guid><category><![CDATA[how-to]]></category><category><![CDATA[personal-experiences]]></category><category><![CDATA[health]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Wed, 20 Dec 2017 15:39:29 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2017/12/fish.jpg" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2017/12/fish.jpg" alt="Fish bone stuck in throat? Just Bong problems!"><p>If you are a bengali, it might not be new to you. It is so common that when asked, my aunt was actually able to suggest a medicine for it. I was dumbstuck at that too; Like seriously? there is a medicine for that!</p>
<h3 id="howdidithappened">How did it happened?</h3>
<p>Being away from home makes us crave for home made delicacies. It happens with everyone. And when you are that fond of native cuisine, yo go ahead and try some recepies on your own. It's either Youtube on screen or Mom on phone, and your cooking lessions are set.</p>
<p>I am blessed with friends and flat mates who are great at cooking. This was just another day when we decided to make <a href="https://www.google.com/search?q=muri+ghonto">Muri Ghonto</a>, a bengali cuisine which is also known by 'Fish head curry' sometimes. I will skip the recepie here but the end result, it was just luscious. Delicious and perfect combination of crunchyness and tenderness! We we enjoying our meal and suddenly I felt a huge urg..... <strong>Aaaaa Chooooo !!!!</strong></p>
<p><img src="https://blog.tanay.co/content/images/2017/12/f01.jpg" alt="Fish bone stuck in throat? Just Bong problems!"></p>
<p>Now I had having experienced this situation before, took a big chunk of white rice and gulped it down. The sensation was still there. I though it went away and I am still feeling some kind of psychotic after effects. We finished our meal and went to bed later on.</p>
<p>Next day I was still feeling the bone stuck in my throat somewhere. I went on to see an ENT specialist. She tried her best and tried some blind efforts on an approximate area that I was able to define.</p>
<blockquote>
<p>Pin bones are so small that they are hardly visible. You might be able to touch and feel if it's nearby.</p>
</blockquote>
<p>After few vague attemps, we though we were successful. She gave some antibiotic to heal the tear that might be a resultant of our mini culprit.</p>
<p>Three day course. Completed.</p>
<p>Oh boy! I was still feeling uncomfortable while gulping down. It has been a week almost now and started scaring me a little. I searched web, followed a lot of <a href="https://www.littlethings.com/fish-bone-stuck-in-throat/">home remedies</a> but to no use. Nothing helped in my case.</p>
<blockquote>
<p>In my case the bone was stuck in upper wall of oral cavity. Most of them only works if it is in your throat or food pipe which can be pushed downward.</p>
</blockquote>
<h3 id="thewinningstory">The winning story</h3>
<p>In the evening, there was a casual conversation going on with my aunt when I bought up this topic. She laughed her lungs out and then asked me why haven't I caller her earlier. She asked me to get SILICEA tablets from a homeopathy pharma nearby. Looks like it is not so unusual in our family.</p>
<p>The very next day, I ran through a Homeopathic store near to my office. Based on my age, they gave me a bottle of <strong>SILICEA 6X</strong> and asked me to take <strong>4 tablets thrice a day after food</strong>. After day one itself, I started experiencing changes. I might have continued it for another day or two and the bone dissolved completely. Though I am not sure if dissolve is the right word to use here, it didn't just vanish. The prickly feeling went away slowly and thus my assumption.</p>
<blockquote>
<p>You can just swallow 4 / 5 tablets (mentioned dosage for your age). It diffuses on coming in contact with your saliva, no need to take it with water.</p>
</blockquote>
<p>Finally my war was over. I was able to eat properly once again. If you are going through similar phases, you can try that medicine. It is not that expensive. The whole bottle cost me around INR 75.00 and I still have more than half left with me. If you are unsure, please run the components through your doctor to see if they might have any side effects on you. Hope it helps :-)</p>
</div>]]></content:encoded></item><item><title><![CDATA[Innovative Film City Bengaluru, worth a day spending?]]></title><description><![CDATA[Planning a trip to Innovative Film city? Get a brief idea with some visual hold on what you will be exploring there. Read more to find out if it is going to be worth your day.]]></description><link>https://blog.tanay.co/review-innovative-film-city-bengaluru/</link><guid isPermaLink="false">5a08335097bc0402e7235af1</guid><category><![CDATA[weekend-getaways]]></category><category><![CDATA[Bengaluru]]></category><category><![CDATA[places-review]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Tue, 14 Nov 2017 09:07:32 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2017/11/innnovative-film-city.jpg" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2017/11/innnovative-film-city.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"><p>As the weekend apprroaches, most of the Bengalurians start thinking of a place to escape out. Daily hustle, blood red traffic status and five days of non stop work load, ah same story bro.</p>
<p>We, a group of four, had already spent our Saturday recovering from post week trauma and were desperately looking into something to bet our Sunday on. That's when it pops out in our feed. And without much thinking, we booked an ola rental and started our micro voyage of exploring the film city.</p>
<blockquote>
<p>Get a round trip rental, if you are not taking your personal vehicle. It is quite difficult to get a cab there.</p>
</blockquote>
<p>We arrived earlier than expected. May be bangalore was sleeping that day :D<br>
Weather was fine; A little cloudy, but a great one for walking around. Got our tickets and walked towards the entrance.</p>
<p><img src="https://blog.tanay.co/content/images/2017/11/entrance.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<blockquote>
<p>Cards are accepted in ticket counter. And they do charge extra for camera.</p>
</blockquote>
<p>There are few 3D galleries to pose around. You have to be at a particular position to get a hold on the perspective. It will be exciting, if you haven't seen one before.</p>
<div class="f-group">
<p><img src="https://blog.tanay.co/content/images/2017/11/gal1.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/ga3.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/gal2.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
</div>
<p>You will have a place next, decorated and filled with props to take fun portraits. Plus there will be a lot of crowd to photo bomb your perfect snap 😅</p>
<div class="f-group">
<p><img src="https://blog.tanay.co/content/images/2017/11/p2.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/p3.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/p4.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/a1.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
</div>
<p>With tickets, each of us were entitled to play small games like Archery and Angry birds look-alike. Extra shots were paid, and price varies varies between INR 50 ~ INR 180.</p>
<p>Moving forward, there will be an open courtyard which is great for some alluring photo shoot. The area is surrounded with replica of antique buildings (which we were not allowed to explore). I guess, they must be void or empty placeholder for shooting models. Nevertheless, the exterior were pretty amazing to look at.</p>
<div class="f-group">
<p><img src="https://blog.tanay.co/content/images/2017/11/g0.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/g1.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/g2.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
</div>
<p>Then comes the <a href="https://en.wikipedia.org/wiki/Kabali_(film)">Kaballi</a> movie set. Don't get your hopes hight as it is just an over hyped enclosure, filled with screens playing choosen snippets from the movie. And a big aeroplane nosed out from the block.. may be worth a few clicks, if you can be creative enough. They have dress and watches on display, which were used during shooting of the movie. This place was also filled with miniature models and merchandise.</p>
<p>You will find a small convention center beside, mostly occupied by some corporate people doing some team activities. It can be skipped.</p>
<p>The actual field trip starts here. I will leave a brief review about them, but you need to go see them in person to check them out for yourself. Some of them were good, but many were not maintained properly or has been abandoned. It's so sorry to see that the authorities have failed in management of such a nice facility.</p>
<p><strong>Haunted Mansion aka Scary House</strong><br>
If you have been to one of this room, you know the drill. It was enormous but nothing was working. We entered, followed and exited.. only a couple of sound effects there. On top of that the speakers were poorly hidden.</p>
<p><strong>Mirror Maze</strong><br>
A house full of mirrors where you need to find your way out. This was interesting. Just make sure to stick together. It's better if this place is crowded. More the number of people, more challenging it will become.</p>
<p><strong>Cartoon city</strong><br>
If you have kids with you, they might find it attractive.</p>
<p><strong>Dino Park</strong><br>
Poorly maintained, and none of the creatures were moving. Some even had broken limbs, necks hanging out. There was a meuseum nearby which had some pretty good info and fossil artifacts.</p>
<p><strong>Petting Zoo</strong><br>
Calling it a Zoo will be like redefining the word itself 😂. There was an open area with no fences and just a hoarding. And there my friends were sitting two mammals, none other than <em>Canis lupus familiaris</em>.</p>
<p><strong>Big Boss Set, Wax Museum</strong><br>
For Big Boss fans out there, this will be of huge treat. Though this is for regional (Karnataka) series and not the national one. You can pay extra to get a glimpse of actual action inside the studio. The wax museum was pretty awesome. You will get to see some finely crafted wax statues.</p>
<div class="f-group">
<p><img src="https://blog.tanay.co/content/images/2017/11/r0.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/r1.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/r2.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/r5.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/r6.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/r7.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/r8.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/r3.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/r4.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
</div>
<p><strong>Rides</strong><br>
If you are the big guy and thinking - atleast the roller coaster will be of fun, I am sorry to disclose that it has not been in service for a while. Moreover those rides are not free. There was a toy train, which was working though. For kids, there will be few additional fun packs like bungee jumps and air inflated castle house, etc.</p>
<p>You will find a small carting area beside if you are into gokarting. That one comes for an anddtional price of INR 120 per head (November, 2017).</p>
<div class="f-group">
<p><img src="https://blog.tanay.co/content/images/2017/11/go2.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/go3.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/go4.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/go1.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
</div>
<p><strong>Aqua Kingdom</strong><br>
Probably the only fun thing for grown ups there. The water area has a pool with artificial beach, two giant rides and few smaller play areas. There was a rain dance like structure too, if you prefer open shower 💦</p>
<div class="f-group">
<p><img src="https://blog.tanay.co/content/images/2017/11/w2.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/w3.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/w4.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
<p><img src="https://blog.tanay.co/content/images/2017/11/w1.jpg" alt="Innovative Film City Bengaluru, worth a day spending?"></p>
</div>
<p>Free lockers are available in exchange of a small deposit. Changing rooms are there too, but not a quality one.</p>
<h2 id="wrapup">Wrap up</h2>
<p>There are few situation when you are most likely to plan a trip here:</p>
<ol>
<li>🚫  Preffering it because you haven't been here. <strong>Please spare yourself from visiting this doomed place</strong>.</li>
<li>🚫 Your family is in town and you have shortlisted this as an attraction. I would say you can <strong>skip this one</strong>. Include something else, Bangalore has a lot of other places to be.</li>
<li>✅ You have a kid or you ran out of places, then it won't hurt to be here. It is okay for one time experience.</li>
</ol>
<p>In this budget (ticket price + round trip cost), there are a lot of amazing places near Bengaluru. It will be 2 out of 5 from my experience. I am not saying the place is bad, but the concerned authorities are not very responsible about it. And it will be a disaster for you if you have been to <a href="http://www.ramojifilmcity.com">Ramoji, Hyderabad</a> before. Decide wisely!</p>
</div>]]></content:encoded></item><item><title><![CDATA[Review - House of Marley Smile Jamaica EM-JE041-SB with mic]]></title><description><![CDATA[Had few recommendations from fellow users about the build quality and tough durability of the product. This post is on my hands on experience with House of Marley Smile Jamaica EM-JE041-SB.]]></description><link>https://blog.tanay.co/review-house-of-marley-smile-jamaica-em-je041-sb/</link><guid isPermaLink="false">59a79fde64932e5a6e089201</guid><category><![CDATA[personal-experiences]]></category><category><![CDATA[earphones]]></category><category><![CDATA[product-reviews]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Thu, 31 Aug 2017 14:46:55 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2017/08/marley-41.jpg" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2017/08/marley-41.jpg" alt="Review - House of Marley Smile Jamaica EM-JE041-SB with mic"><p>Few recommendations from fellow users and had heard few good words about the build quality along with the tough durability of House of Marley products. So when my two-year-old earphone which came with my mobile handset, passed away, I thought of buying this one. I was searching for the best within a budget of INR 1000. There were some good competitors like <a href="http://amzn.to/2wknGqp">Sennheiser CX 180</a>, <a href="http://amzn.to/2wUsAfa">Sennheiser CX 275 S</a> and <a href="http://amzn.to/2wjK9DK">JBL T110</a>. I went through the reviews and finally selected the deep brown variant of <a href="http://amzn.to/2eGQdx9">EM-JE041-SB</a>.</p>
<p>The wooden finish and the fabricated cord were giving it a prime look. Within a minute I had decided to go with it. Placed the order, completed the payment and started waiting for my earphones to arrive. As known for its blazing fast services, Amazon delivered the product on the third day itself. Here are few pics from the first unboxing.</p>
<div class="f-group">
<p><img src="https://blog.tanay.co/content/images/2017/08/marley-41-1.jpg" alt="Review - House of Marley Smile Jamaica EM-JE041-SB with mic"></p>
<p><img src="https://blog.tanay.co/content/images/2017/08/marley-41-2.jpg" alt="Review - House of Marley Smile Jamaica EM-JE041-SB with mic"></p>
<p><img src="https://blog.tanay.co/content/images/2017/08/marley-41-3.jpg" alt="Review - House of Marley Smile Jamaica EM-JE041-SB with mic"></p>
<p><img src="https://blog.tanay.co/content/images/2017/08/marley-41-4.jpg" alt="Review - House of Marley Smile Jamaica EM-JE041-SB with mic"></p>
</div>
<p>It's build and finishing was awesome, but I was little disappointed with the sound quality. Not sure, if it was due to some fault or not, the <strong>bass were not deeper</strong>. There was <strong>no clarity</strong> when it comes to mids vs lows either. As far as <strong>treble</strong> is concerned, it matched with my previous earphones.</p>
<p>You will get three sizes of eartips to choose from. They were tight, comfortable and did a fantastic job in blocking surrounding noises. Coming to the audio input, I and my girlfriend talked about an hour with these pairs on. I never felt my ears hurting during this whole time, neither it came off once. Though you need to hold the microphone close to your mouth while speaking</p>
<blockquote>
<p>No, I was not expecting a crystal clear cuckoo chirping in my ears with a budget earphones; But I was expecting a decent *dwoof* *dwoof*, while listening to bass numbers.</p>
</blockquote>
<p>On high volume and with some tuning with an equalizer, you can make it work. But I think we can get a better earphone in this range. There were almost a thousand people praising the product and yet I found it 'Not so good'. May be I got a defective one, who knows. A thing to note here - when you go to the <a href="http://amzn.to/2eGQdx9">product page</a>, my product (dark brown in colour) was listed at the cheapest price. There are other variations of the same model too. They might be good. I have no idea about them.</p>
<p>I was not quite happy with my purchase and issued a return request. Amazon being Amazon, refunded the full amount within 3 days. I placed an order for <a href="http://amzn.to/2wjK9DK">JBL T110</a> as soon as my refund got initiated.</p>
</div>]]></content:encoded></item><item><title><![CDATA[[Solved] How to get amount of time changed from TIME_SET in android]]></title><description><![CDATA[Using TIME_SET to track down time changes? But you are receiving this intent more frequently than expected? Or you need the old time or the difference between them? The post is all about what causes it in the first place and how to get rid of it along with the answers to your questions.
]]></description><link>https://blog.tanay.co/android-how-to-get-amount-of-time-changed-from-time_set/</link><guid isPermaLink="false">599fa09464a41936b28174fe</guid><category><![CDATA[android-development]]></category><category><![CDATA[how-to]]></category><category><![CDATA[android-intent]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Fri, 25 Aug 2017 05:15:30 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2017/08/time-garden.jpg" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2017/08/time-garden.jpg" alt="[Solved] How to get amount of time changed from TIME_SET in android"><p>Using <strong>android.intent.action.TIME_SET</strong> to track down time changes? But your log shows you are receiving this intent more frequently than expected? Or for some reason, you need to find out the old time (the time before changing) or the difference between new time and old time. But how to do that? Android doesn't send any more information in that broadcast.</p>
<h3 id="whatishappening">What is happening?</h3>
<p>Most of the devices are setup to sync time from the network. And some devices does that more frequently than others. And thus the TIME_SET broadcast is fired every time the device synchronizes. There might be other reasons too, like some app setting time zone or time itself explicitly. You never know what's going on in an user's handset.</p>
<h3 id="solution">Solution</h3>
<p><a href="https://github.com/chrisport">@chrisport</a> came with a bright idea to hack a way around. You can view his implementation <a href="https://github.com/chrisport/setTimeIntent#set_time-intent-calculate-previous-time">here</a>.</p>
<p>The main idea is to <strong>store</strong> a reference <strong>which is not changing</strong>. A user's time can change according to his time zone, or due to NTP / network updates. But what about device boot time? If a user's device was booted 2 hours ago and even if the time gets changed within this 2 hours, the bootup time will still be 2 hours. Similarly, after 1 hour from now, it will be 3 hours; regardless of other variables.</p>
<p>We can use this to get an estimate of how much the time has changed. The trick is to calculate the <strong>difference in between boot time and device time</strong>.</p>
<pre><code class="language-text">
For eg, right now the date time in your area is : Aug 04, 2016 09.00 AM
In UTC: 1470281400000
# UTC might vary, depending on your timezone. Mine was IST while calculating.

You have switched on your mobile at say 06.00 AM in the morning.
In UTC: 1470270600000
That means the system is up for 10800000 milliseconds, i.e. 3 hours ago.

Now the difference between your device time and time since the device booted : 
1470281400000 - 10800000 = 1470270600000

</code></pre>
<p>Fast forward 2 hours</p>
<pre><code class="language-text">
After 2 hours, the date time in your area will be Aug 04, 2016 11.00 AM
In UTC: 1470288600000
But since your device was started at 06.00 AM [1470270600000 UTC], the system is up for 5 hours.
# 1470288600000 - 1470270600000 = 18000000 ( 5 hours )

Difference between device time and time since booted :
1470288600000 - 18000000 = 1470270600000

## The delta still stands at 1470270600000

</code></pre>
<p>This happens because of equal intervals. When there is no change in actual time, after 2 hours, the device time is ahead by an equal amount to that of device boot up time ( 2 hours ).</p>
<p>Done explaining, the code is much simpler. You just need few additional changes to your <code>BroadcastReceiver</code> to detect a rougue one.</p>
<pre><code class="language-java">
public class TimeChangeReceiver extends BroadcastReceiver {
    
    // if time change is greater than 30 seconds, consider it. 
    // Else just assume it as an redundant broadcast
    private static final long THRESHOLD = 30 * 1000; 

    // A static variable to store last difference.
    // By default, it will be 0. So the first case will always be triggered.
    // It is not a recommended way. Using static just for demonstration.
    // You should use SharedPreferences to store and fetch this value. 
    private static long lastRecordedDelta;

    @Override
    public void onReceive(Context context, Intent intent) {
        
        // time change broadcast received
        long delta = System.currentTimeMillis() - SystemClock.elapsedRealtime();
        long timeShift = delta - lastRecordedDelta;

        if (Math.abs(timeShift) &gt; THRESHOLD) {
            
            // User tried to change the time.
            // do your task here

            // timeShift is the difference between old and new time
            // u can create a new Date object using this info
            if (lastRecordedDelta != 0) {
                // static variables defaults to 0, if not initialized.
                // This won't work for first broadcast.
                Date now = new Date();
                Date old = new Date(now.getTime() - timeShift);
            }
        }

        lastRecordedDelta = delta;
    }
}

</code></pre>
<p>That's all. In case frequent TIME_SET broadcast was causing you trouble, now you can encapsulate your main logic within the above wrapper. You will also have the value of time shift and old time if required.</p>
<blockquote>
<p>You should also consider replacing the static variable <code>lastRecordedDelta</code> with some sort of local storage (SharedPreferences or whatever you are using). You can improve further by creating a separate on-boot listener to set this time difference on device startup. That will remove the first run constraint from the above snippet.</p>
</blockquote>
</div>]]></content:encoded></item><item><title><![CDATA[[Solved] SSLException or SSLHandshakeException due to SSLv3]]></title><description><![CDATA[If have been a victim like me, struggling to get an HTTPS request working on Android. The post lists a solution for situations where you have encountered an SSLException or SSLHandshakeException while making the request on devices running os lower than LOLLIPOP.]]></description><link>https://blog.tanay.co/android-sslexception-or-sslhandshakeexception-due-to-sslv3/</link><guid isPermaLink="false">599ee8f3068bdb333aa816e7</guid><category><![CDATA[android-development]]></category><category><![CDATA[how-to]]></category><category><![CDATA[https]]></category><category><![CDATA[SSLException]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Thu, 24 Aug 2017 15:24:53 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2017/08/android-dev-1.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2017/08/android-dev-1.png" alt="[Solved] SSLException or SSLHandshakeException due to SSLv3"><p>I see you have been a victim like me, struggling to get an HTTPS request working on Android. The solution below is for situations where you have encountered an <code>SSLException</code> or <code>SSLHandshakeException</code> while making the request on devices running os lower than LOLLIPOP.</p>
<h3 id="getmetothepoint">Get me to the point</h3>
<p>If you have been into some server side, you should be aware of a <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566">bug</a> which leaves a serious vulnerability. If you are not, you can assume that the guy who controls your server is well responsible and has managed to <strong>disable SSLv3</strong> protocols on your servers. And hence this error.</p>
<p>Now devices running LOLLIPOP or greater can safely fall back to TSLv1.1 or TSLv1.2 to continue the handshake. The problem occurs in devices running lower than API 21.</p>
<h3 id="whatthehellishappeninghere">What the hell is happening here?</h3>
<p>To communicate securely over HTTPS, your client opens a connection to your server. There are different protocols for this (TSL / SSL). After the launch of SSLv3, it was widely accepted until the bug was reported. But till then, it had made it's way into several other dependencies. Most clients (<code>OkHTTP</code>, <code>HttpsURLConnection</code>, etc)  will follow device specific configuration if some protocol is unavailable or an unsuccessful connection is encountered.</p>
<p>The pain is, however, even if the protocol is supported in the device, it might not be available by default. Google lists the available vs default state of protocols in different API versions as follow :</p>
<p><img src="https://blog.tanay.co/content/images/2017/08/client-socket-ssl.png" alt="[Solved] SSLException or SSLHandshakeException due to SSLv3"></p>
<p><a href="https://developer.android.com/reference/javax/net/ssl/SSLSocket.html">Click here</a> to read more.</p>
<p>So basically, your server is not accepting a connection over SSLv3 and your client profoundly blames the server for closing the connection.</p>
<blockquote>
<p>TLDR; Server has SSLv3 disabled and client is fixated over it</p>
</blockquote>
<h3 id="isthereafixavailable">Is there a fix available?</h3>
<p>Yes! There are ways around it.</p>
<p>Simply tell the client not to use SSLv3. <strong>Fall back to TSLv1.1 or TSLv1.2</strong>, whatever your server speaks. You might want to check with that server guy if you are not in charge.</p>
<h3 id="givemethefixalready">Give me the fix already</h3>
<p>If you have googled for solutions, you must have encountered one using a custom <a href="https://developer.android.com/reference/javax/net/ssl/SSLSocket.html">SSLSocketFactory</a>. The idea is to wrap up SSLSocketFactory and update each socket to use TSL instead of SSLv3. The guys over <a href="https://gitlab.com/groups/bitfireAT">bitFire</a> have done a wonderful job by open sourcing their custom class. Yes, you can write your own too, but I will save some time by reusing what's already been engineered.</p>
<p>Please download the file from <a href="https://gist.github.com/tanaykumarbera/b84281961f5cfe74035ad94fe251fc0d">here</a>.</p>
<p>The constructor is accepting an instance of Trust Manager. If you have one, you can pass it on. And if you don't, follow the steps below to create a new one.</p>
<pre><code class="language-java">
X509TrustManager trustManager;
try {
    TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    trustManagerFactory.init((KeyStore) null);
    TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
    if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
        throw new IllegalStateException(&quot;Unexpected default trust managers:&quot; + Arrays.toString(trustManagers));
    }
    trustManager = (X509TrustManager) trustManagers[0];
} catch (NoSuchAlgorithmException e) {
    trustManager = null;
    Log.e(&quot;TrustManager&quot;, &quot;NoSuchAlgorithmException : &quot; + e.getMessage());
} catch (KeyStoreException e) {
    trustManager = null;
    Log.e(&quot;TrustManager&quot;, &quot;KeyStoreException : &quot; + e.getMessage());
} catch (IllegalStateException e) {
    trustManager = null;
    Log.e(&quot;TrustManager&quot;, &quot;IllegalStateException : &quot; + e.getMessage());
}

</code></pre>
<p>Now all you need to do is use an instance of this new <code>SSLSocketFactoryCompat</code> of yours, instead of device default. I will put on snippets for <strong>OkHTTP</strong> and <strong>HttpsURLConnection</strong>, but if you are using any different client just go through their documentation on how to set custom SSL Socket factory. It should be easy as calling a set method I believe.</p>
<h4 id="okhttp">OkHTTP</h4>
<pre><code class="language-java">
OkHttpClient client = new OkHttpClient.Builder()
    .sslSocketFactory(new SSLSocketFactoryCompat(trustManager), trustManager)
    .build();

</code></pre>
<p>Try to use a single instance of OkHttpClient for all your requests. It gives a significant boost to performance as well as resource management.</p>
<h4 id="httpsurlconnection">HttpsURLConnection</h4>
<pre><code class="language-java">
HttpsURLConnection httpsURLConnection;
try {
    URL url = new URL(&quot;https://www.quantumbits.in&quot;);
    httpsURLConnection = (HttpsURLConnection) url.openConnection();
    httpsURLConnection.setSSLSocketFactory(new SSLSocketFactoryCompat(trustManager));
} catch (Exception e) {
    e.printStackTrace();
}

</code></pre>
<p>You can also update the default SSLSocketFactory which will be inherited by the new instances of this class.</p>
<pre><code class="language-java">
HttpsURLConnection.setDefaultSSLSocketFactory(new SSLSocketFactoryCompat(trustManager));
// then you can just open a connection directly
URL url = new URL(&quot;https://www.quantumbits.in&quot;);
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();

</code></pre>
<p>But I won't recommend doing so 😄</p>
<blockquote>
<p>The custom wrapper that we are using has a lot of cipher suites enabled by default. You can safely disable the ones which are not in use for your server. Just remove the Strings from the list of available ciphers.</p>
</blockquote>
<p>Go ahead and try making the request which was throwing SSLException before. It should be able to connect successfully.</p>
</div>]]></content:encoded></item><item><title><![CDATA[sudo systemctl start ghost - my journey to start writing]]></title><description><![CDATA[It was a long dream to start a publishing platform of my own. There have been unsuccessful attempts before which never made it to production. This post explains what inspired me and how I achieved it.]]></description><link>https://blog.tanay.co/my-first-post/</link><guid isPermaLink="false">599e955b068bdb333aa816de</guid><category><![CDATA[blog]]></category><category><![CDATA[life-event]]></category><category><![CDATA[personal-experiences]]></category><category><![CDATA[ghost]]></category><dc:creator><![CDATA[Tanay Kumar Bera]]></dc:creator><pubDate>Thu, 24 Aug 2017 10:10:00 GMT</pubDate><media:content url="https://blog.tanay.co/content/images/2017/08/workspace4x3.jpg" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://blog.tanay.co/content/images/2017/08/workspace4x3.jpg" alt="sudo systemctl start ghost - my journey to start writing"><p>It was a long dream to start a publishing platform of my own. There have been unsuccessful attempts before which never made it to production. Funny that we have 168 hours with us and yet we find out excuses of not having enough of it. We do have ample amount of time for everything, but not everything is in top of our priority list.</p>
<blockquote>
<p>I don't have time = It's not in my priority</p>
</blockquote>
<div class="f-video"><iframe width="560" height="315" src="https://www.youtube.com/embed/n3kNlFMXslo?rel=0" frameborder="0" allowfullscreen></iframe></div>
<p>Above is a Ted talk from <a href="https://twitter.com/lvanderkam">Laura Vanderkam</a>. Somehow it popped up in my feeds and boy I have a different perception since then. I might be delaying some work today also, but I now know it is not about the lack of time. The problem is in me. I do not feel the job is of that importance that I will dive in right away. But the question is, will I do it tomorrow? Or the day after tomorrow?</p>
<h4 id="amiapunctualman">Am I a punctual man?</h4>
<p>I can see my friends who know me well, laughing their hearts out. <strong>NO, I am not.</strong> Now if I know winter is coming, I will start gathering my troops since autumn. I formed my own rules which I am comfortable with - if it can be done quickly, I will do it now. If not, I will do it in parts. See, I know I am lazy; There is no turning back from it. This is an agreement I signed up with the devil inside. Either do it now and enjoy the rest of your time, or complete one frament at one time for the cost of your 'me time'.</p>
<h4 id="wherethefckisthereleventcontent">Where the f@ck is the relevent content?</h4>
<p>I have a bucket full of such wishes which I have kept for some later time. And while writing this, it's already 24 years and 2 months! How long now?</p>
<p>I always wanted to craft my own site. <a href="https://ghost.org">Ghost</a> came to rescue. When I first learned about how simple it was to create a theme for this blogging platform, I was in love with this beauty. (No babe, I love you more. Trust me, this is not a competition). One day I just jumped it and started developing for it. Didn't knew when would I be able to see the first post, but kept on the working. Never counted how long it took. I just knew from todays failure - not to repeat the same one tomorrow. The development phase was fun. I also got to pick up some cool tricks on my way.</p>
<h4 id="nowwhat">Now what?</h4>
<p>I plan on improving this theme and continue my writing saga. If you would like to catch up, please follow me on <a href="https://twitter.com/tanaykumarbera">twitter</a> and <a href="https://www.instagram.com/tanaykumarbera">Instagram</a> or just drop in to say hi 👋 !.</p>
</div>]]></content:encoded></item></channel></rss>