Posts

da Vinci of the 21st Century

Image
According to many sources, Leonardo Da Vinci is known for hiding secret codes and messages in his art work. In the modern era, digital canvases and images have a greater role to play.
An image of width w and height h contains x h pixels. Changing the RGB values by a small value would not be detectable to naked eye. In this blog post, let me show you how to encrypt and decrypt messages using this principle. We'll do both encryption and decryption using JavaScript.

To get started with, I downloaded a very nice picture of Mona Lisa from Wikipedia (. I also created an image with black text in a white background, which I shall not show here (message.jpg).


Next, I setup a good HTML platform to run back to back JavaScript commands, which would automatically load all the images I need. To avoid CORS issue, I have been running a SimpleHTTPServer to open up the webpage.

<html>
<body>
<img src="725px-Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg" id=&q…

Image to a string in JavaScript

Image
There may be various methods to convert an image into a one dimensional data. JavaScript enables you to convert and store images in string format and most modern browsers would be able to render that image.
For instance, the following string contains Google's logo. You can check this by copy-pasting it on a browser addressbar. It is possible that some of you may think the the image could be loaded from an external website. For those people, I would like to recommend them to turn their internet off and paste the following on their addressbar.

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALgAAAA8CAYAAADVEnAJAAAOvklEQVR42u1dCZBcRRluyM4Sbg9QuUTFYAhy7Zs3G2Nw5r2ZTWKMWBCXQ5QzIncEFIqjGGtnZpdwaEUOIYcFlBwVRBA5wh7hUIIQCFgkJCAWBUWSnZ3N9d7MXgk7/p/sZje72/3umR2rv6quDOyb1zXd3/v77+///37MD0STxapYY6FWT+ev0zP5h7W0sTqWyWdjGaNA/13UU0Yf/ZvT08bbWjr/GH2+Qc8YJyv3FUNMQmK8Qk8XIrGM+Qc9ld8CIjttn33PvC/elD+JSUiMFxAp64igL4GkvrW08TytADVMouIQfnRucazGKg11qe6v62nzryBkIC1l9NO/d0eT2f2YhCR4ia32T2MpMw8iBt20TP79eIN5HJOQB…

Estimating the value of Pi using Monte Carlo Method

Image
The very first moment I was shown this, I was amazed. Estimating something using random events is pretty amazing. The first time I did this in MATLAB, but now, I think I will attempt to do the same in JavaScript.
The undelying concept of Monte Carlo Method is to use randomness to determine the value. The method is often used to solve problems that are hard to determine exactly, when there is enough statistical data available.
Let us define a square centered at the origin with side of length 2. A circle centered at the origin is inscribed in this square.


The assumption that we are using in this method is that if we randomly take a few points within the square, the ratio of the number of points that falls within the circle to the total points taken is equal to that of the area of the square and the circle. That is,
Area of square / area of circle = totalRandomSamples / totalPointsInCircle Let us write a JavaScript program that could do perform this with a huge number of random sample p…

Programming bouncing ball in JavaScript

While studying Newton's laws of motion during my schooldays, I found some of the questions related to bouncing ball quite fascinating. The sheer number of different kinds of questions that one could come up with just a ball bouncing on the ground is quite a lot.
My attempt is to create the example as simple as possible. I would not be defining additional classes; I would be using the position value which is already present in the DOM Element and adding velocity as a parameter to the DOM Element.

First, let us define the HTML and CSS to get the visual appearance of the ball and the floor right.

<html>
<style>
#ball{
    position: absolute;
    left: 50%;
    top: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #005eff;
}
#floor{
    position: absolute;
    bottom: 2px;
    background: #000;
    width: 100%;
    height: 20px;
}
</style>
<body>
    <div id="ball"></div>
    <div id="floor">&l…

Nine year anniversary for BuddyGo

Image
It has been nine years since I bought the domain buddygo.net. Prior to buying a .net domain, I used to use a .tk domain as it was free. As I started this project during my childhood, it was hard for me to convince others to pay for this, but eventually, I saved up some money and did it. For a few years, I paid for the domain just for the sake of keeping the ownership.



As I have mentioned in one of the previous blog posts, BuddyGo started of as a social network. Later, I started a few blogs in different subdomains which turned out to have pretty high traffic. In the subsequent years, I had to take the project down for many reasons, the main one being my academics.

Bringing it back up as a blog, I believe, is a good decision that I made and I think I will keep on writing more posts.

Cheers!

Slideshow on Google Images

Image
I opened Google Images and searched for Batman, which is probably my favourite Super Hero. I had connected my laptop to a TV screen and I wanted to see all the images as a slideshow. And, just like many other posts in this blog, I started using the Chrome Developer Tools.
I clicked on the first image. The image was being displayed on the side and a button to move to the next image came in. I right-clicked on the button and did an Inspect and I found that the button was having classes KJaJCe irc-rab. I ran the following command to see if there are other elements with the same class.

document.getElementsByClassName('KJaJCe irc-rab')

I saw that there were three elements, but the button to go to the next image was always having an index of 1. So, I went ahead and did the following:

a = document.getElementsByClassName('KJaJCe irc-rab')[1];
a.click();
Each time I ran a.click it showed me the next pic on the right-hand side and I was convinced that if I keep this in a setInt…

Creating a Neural Network to Predict Periodic Data

Image
Two years ago, Arijit Mondal,  a professor of mine who was teaching us a course on Deep Learning, asked a question on how to make a Neural Network that can predict periodic data. The students started shouting out their own version of answers, most of them involved the usage of some form of recurrent neural network structure. I had a different answer.
I was not a very good student during my initial semesters during my bachelors. I missed several classes due to the lack of motivation which were supplemented by the change in environmental condition that I had been used to growing up. But, I could recollect some of the things that were discussed in a Math course, which was regarding fourier series. Just by using a bunch of sine waves, the series was able to approximate many functions to an excellent accuracy. How is this any different from the Universal Approximation Theorem that was tought during the initial lectures of this course?

It striked me - the easiest way neural network can lea…

Transferring Files between Computers and Phones using Wi-Fi

Image
Phones are essentially miniaturized computers. If you connect your phone to a monitor, keyboard and mouse, it essentially becomes a computer. In this article, let us discuss about how to use an Android phone or a computer as a server and transfer the data into another phone or computer.

Doing this procedure on an Android device, you just need to install the app named Termux, which provides you with a Linux Terminal on Android.

If you don't have python installed already, install it using apt-get or apt using the respective commands listed below on your Linux Terminal or Termux. Note that admin privileges may be required to do so.
apt install python
apt-get install python After you are done installing, before you create the server, you need to know what your IP address is so that other devices can access it. To obtain the IP address, simply type in the following command:
ifconfig 

In this case, the highlighted portion in the image above is the IP Address, 192.168.43.182. Now let us…

Extracting Stock Price Data Trend from Google Search to Train LSTM Network

Image
I am not very good with designing my own neural networks. I have attempted to create a few in the past, some worked out fine for proving certain points that I wanted to make, but whenever I tried to make something to participate in a competition, things were not very well. In this post, I do not intent on creating an LSTM based neural network to predict stock prices, rather simply use Google as a tool to extract the stock trends from the graphs.

To get started, search for "Amazon stock price" on google. You would be able to see a pretty nice graph. On right clicking on the graph and clicking on Inspect and reading through Elements in the Developer tools, it can be observed that the graph is rendered using Scalable Vector Graphics or SVG. This is an XML-based vector image format and the data required to create such a graphic would be available in a format that we'll be able to read. I also observed that the required SVG image has a class name uch-psvg and there is only o…

Sending a Facebook Message Challenge: Harder than it looks

I have been having conversations with a friend regarding how easy it is to use JavaScript to automate a lot of processes that we usually do, why it is easier to program in an interpreted language than compiled language, etc. Pondering about these conversations, I challenged myself to send a message to my girlfriend on Facebook Messenger using JavaScript console alone.

Before I started, these are the ground rules that I set:

I can use both keyboard and mouse, but the usage should be restricted to the JavaScript console alone.No other tab in the developer tools other than JavaScript console shall be used.I shall start with about:blank as the start page.

The first step is to open Messenger. That step was pretty easy considering the fact that I already knew how to use the window object to my advantage. I used the following command to open Messenger.

window.location.href = "http://www.messenger.com";
Luckily, I had already logged into Facebook and the cookies were not cleared. So…