Posts

Featured post

Parsing with Mechanize

Image
Hello !  In my previous  article , we discussed about Nokigiri , a very useful HTML and XML parser i.e it helps in parsing or scraping the information available on a web page to use it in the Ruby program. But sometimes we just want to trigger some action , click button or automate the process on a website from a Ruby program.For example scheduling a social media post , automating a feed back (Yes , we are forced to give the feed back to the faculties on a web portal) or just submitting a form and many other features that are not provide by that particular website but you have to do it manually.This is where Mechanize comes to the rescue . It is one of the coolest ruby library that is very useful in scrapping as well as triggering any action on a web page. What's Mechanize ? According to the The Bastards Book of Ruby , "Sometimes, the challenge is navigating to the right page. This is the case with many websites that require you to fill out a form. It's not

Parsing With Nokogiri

Image
I was reading an article from our blog about extracting all the links from a webpage with python.Have a look , that's a well written article.So ,I decided to write an article about extracting links and images links with Ruby using Nokogiri . What's Nokogiri ? Nokogiri is a library that acts as HTML/XML parser. In simple language, if you want to extract a piece of information from a website to use it in your program what would you do?  Suppose we want to extract the information in <div id="abc"> to use it in our program,either I will copy the source of website into a text file manualy  and  then search through the whole document or I can use a library that can help me in extracting the information directly from the website.Nokogiri is one such library. Using Nokogiri   Step 1.        Install the gem 'nokogiri' by typing  " gem install nokogiri" .   Step 2.                                                                               

what happens when you accidently initialize '/home' as git repository ?

Image
Hello there, This was a long weekend for us(college mates) as study leave is going on and to make use of it I decided to initialize some pending projects.Yeah! this is like a regular holiday for us. I had few 'energy drink'(s) and begin my work ,before creating a directory i accidently typed "git init" and initialized my whole /home directory as git repositiory . I ignored that as I was highly 'energetic' and begin my work. What was the Result of this deed ? Well, I had around 5000 changes staged for commit in that repository.I opened  Visual Studio Code and clicked on the "Source Control" (or type 'ctrl+shift+g') and found this - You can also find out this by typing "git diff" or "git diff HEAD". Why 5000 changes? There are many changes that takes in the system,for example ,every command you type updates the '.bash_history' and simillary there are many files that gets updated.Those changes were

Using Sinatra: Building a Web Application (part ll)

Image
Hi There! in the previous article you learned about setting up Sinatra and HTTP request methods.In this article we will use the things that we learned to build a web app. I've changed my mind about "Scissor ,Paper ,Rock " game.We'll now be encrypting and decrypting a key using my algorithm and will learn the basic of ERB. What's ERB ? " Embedded Ruby is a templating system that embeds Ruby into a text document. It is often used to embed Ruby code in an HTML document, similar to ASP, JSP and PHP."So we'll be embeding our code on a HTML Page. ERB Syntax : The key concept of ERB is simple: it allows you to write HTML with bits of Ruby code interspersed with regular HTML. Before the template is sent back to the user, it's compiled. This means that any Ruby code in the template is executed, and all we're left with is regular HTML. like this: < h1 > Today's date is < %= Time.

Debug django webapps like react native

Image
Introduction Most websites/webapps are now mobile first. Internet browsers these days all have the mobile view that lets you see how the app looks on your phones. But this is not enough to judge the full mobile experience. So, it is better to debug it on an actual phone. To do this, we should either host the app on a server and open the URL on your phone. Or you can locally host it on your WiFi network. What happens in react native React native is a framework of javascript that allows you to build native mobile applications. Debugging in it is made beautifully. A server is started, this prints a QR code on the terminal itself. This QR code is then scanned through an app called Expo. This app automatically installs the app on your phone and runs it. This is the most convenient way I have ever done debugging. What happens in Django In Django, you have to run an HTTP server locally and either debug on your browser or connect your phone on the same network and access it on your

Using Sinatra :A Web App Development Library(Part l)

Image
Ruby is blessed with several web application frameworks such as Ruby on Rails , Merb , Nitro,  Camping and Sinatra.Many of us might have heard about Ruby on Rails ,In simple words, Sinatra is an alternative to it and the other frameworks mentioned above.Sinatra was designed and developed by Blake Mizerany in 2007 and named after musician Frank Sinatra. In this article we'll learn about : i.   Installing and Setting up Sinatra ii.  Handling the HTTP Request Prerequisites:  One Must Know Ruby to proceed further. So let's begin : Installing and Setting up Sinatra:   i.  Open the Terminal. ii.   Type "gem install sinatra" without " ". Voila! The gem got install.Now its time to Test it.So, for this we will create  file named "app.rb" and type: require "sinatra" #to use the sinatra module and run the app by typing "ruby /directory_name/app.rb" without ""  and then go t

Different tools for serving static files through HTTP

Image
Introduction Serving static files through HTTP is not a difficult task. Every little web developer is doing it. But not many people understand the real action that is happening underneath. HTTP protocol is very simple to understand and needs to be understood by everyone as it is one of the most used protocols in the world wide web. Working of HTTP The working of the protocol is very simple. It works on the basis of the request and response. A client (generally a user's browser) makes a request for a particular file and the server it. There are 4 basic types of requests: GET, POST, PUT and DELETE. GET is the most used type of request. When a URL is entered into the browser, the browser makes a GET request to the server. The server serves the required HTML file and the browser renders it. But for this, we need to have a server which is capable of accepting requests and processing them. There are several tools available to make a simple HTTP server. We are going to hav

Fix "0xc00007b" error in Windows

Image
It happens the best of us. We have a new game to play now and after spending hours downloading it, you launch it and are greeted with an error.  The fix for the problem is not really given by a website clearly and I want to share the solution that works for everyone! Familiar with this? > What exactly happens?  As soon as you encounter the error code 0xc00007b, a dialogue box may prompt up on your screen and flashing the message stating, “The Application was unable to start correctly (0xc00007b). Click OK to close the Application” > The reason why :  There can be various scenarios under which you encounter error code 0xc00007b. You may get this error while doing any of the following: ● You might be trying to play a Game on your PC and after launching the application, error code 0xc00007b may flash on your screen. ● You might be launching software but unfortunately the error code 0xc00007b may resist you to do so. ● You may encounter 0xc00007b error

Hands-on with the new XDA Feed App

Image
Greetings Droids,  Today we are going to explore an app released by XDA called " XDA Feed - Customize Your Android ". It's the universal version of the app already available for a couple of devices. It's available in  Google Play Store  and virtually any device running Android Lollipop and higher (5.0+) . The purpose of the app is believed to curate the best stuff from the XDA forums. As going through the forums can be a daunting place for a lot of people. It's easy to miss out on latest ROM releases or must have icon packs.  All content from feed is handpicked by humans to ensure quality.  If you like to modify your phone or stay up-to-date (with posts notifications) with the latest the community has to offer then this app is what you need.  Earlier, the app was specially made for  Pixel, Pixel XL  and  OnePlus 3/3T  which contained device specific content like ROMs, kernals and Mods and also general content like wallpapers, icon packs and themes.

How to serve a django app on a local area network

Image
In this post, I will show you how I automated the process of hosting a django app on a local area network. The usual way to host a django app locally is by running “python manage.py runserver”. This just hosts the app at 127.0.0.1:8000. Now, this app cannot be accessed by others on your network. In order for other devices to access your app, you will have to host the app with the IP address that your computer has on the network. For example, if your IP address is 192.168.1.3, your will have to host the django app at 192.168.1.3:8000. The port number 8000 can be different. To do so, you have to run the command “python manage.py runserver 192.168.1.3:8000”. Now your django app will be hosted on the local area network and can be accessed by others using the address http://192.168.1.3:8000/. To get you IP address, you can run the command “ifconfig” on the shell and find out (or “ipconfig” for windows). And then you copy and paste the IP address in the command.  But