Posts

Learning to use multiprocessing in Python using Pebble package

Image
A popular thread and concurrency management package in Python that I generally rely on is the pebble package. Pebble simplifies parallel task execution in Python, making it easier to leverage the full computing power of multicore systems and improve the performance of concurrent applications. I intend to give a small demo of how to implement this package in a regular piece of code. Let's consider this piece of code that iterates over an array of tuples. Each tuple holds our task name and time duration. We are passing each tuple as argument to a function that performs a basic task(e.g. sleep). There is no concurrency involved here as each loop waits until the previous loop completes all tasks. import time work = ([ "A" , 5 ], [ "B" , 2 ], [ "C" , 1 ], [ "D" , 3 ]) def work_log (work_data): print ( " Process %s waiting %s seconds" % (work_data[ 0 ], work_data[ 1 ])) time.sleep( int (work_data[ 1 ])) print ( " Process

Understanding MTBF (Mean Time Between Failures) and its relation to MTTR (Mean Time To Repair) in Maintenance Management

Image
In the realm of maintenance management, ensuring equipment reliability and minimizing downtime are crucial for the smooth functioning of businesses across various industries. One key metric that helps measure reliability is MTBF (Mean Time Between Failures). In this blog post, we will delve into the concept of MTBF, its significance, calculation methods, and practical applications, drawing insights from reliable sources such as Limble CMMS and UpKeep. 1. What is MTBF? MTBF stands for Mean Time Between Failures. As explained on the Limble CMMS blog, MTBF is an important metric used to measure the average time between failures of equipment or systems. It provides valuable insights into the reliability of assets, aids in maintenance planning, and helps optimize resources. 2. Understanding the Calculation: According to UpKeep's comprehensive guide, calculating MTBF involves dividing the total operational time by the number of failures. This gives us an average estimation of how long eq

Five advantages of Raspberry Pi Zero over Raspberry Pi 3

Image
Raspberry Pi has revolutionized the world of single-board computers, enabling enthusiasts, hobbyists, and professionals to bring their innovative ideas to life. While Raspberry Pi 3 has been a popular choice for numerous projects, the introduction of Raspberry Pi Zero has brought its own set of advantages and possibilities. In this post, I will delve into the advantages offered by Raspberry Pi Zero over its predecessor, Raspberry Pi 3. 1. Compact Size and Affordability: One of the standout features of Raspberry Pi Zero is its compact size. Measuring just 65mm x 30mm x 5mm, it is significantly smaller than the Raspberry Pi 3, making it ideal for projects with space constraints or those requiring portability. Additionally, Raspberry Pi Zero comes with a lower price tag, making it an affordable option for budget-conscious users. 2. Power Efficiency: Raspberry Pi Zero consumes considerably less power compared to Raspberry Pi 3. This makes it an excellent choice for projects that run on bat

My top five self hosted application

Image
I have always loved self-hosted servers. You learn a lot of your craft by managing your own set of applications. You get to troubleshoot setups, identify gaps and even improve server resilience. Besides, they make for a nice free alternative to paid online services. One immediate benefit of self-hosted applications is you don't need an internet connection. It is possible to access them from within the home network with no connectivity. If you do need to access them from outside, there are tons of services available for that in both free and paid tiers. Maybe we'll cover them in another post. On a small note, self-hosted applications aren't for everyone. And they aren't suitable for every purpose. I read this post once where the author went through painstaking steps to set up their mail server. But that's nowhere as reliable as any other online e-mail service provider. Self-hosted is usually a fruit of passion and not commercially viable. That being said, let's l

Web scraping using BeautifulSoup in Python : EAN number vs price from a German e-commerce website

Image
 Input : List of URLs of product category containing list of products to obtain information from. https://www.duo-shop.de/de-DE/List/4/0/0/ https://www.duo-shop.de/de-DE/List/5/0/0/ https://www.duo-shop.de/de-DE/List/70/0/0/ https://www.duo-shop.de/de-DE/List/259/0/0/ https://www.duo-shop.de/de-DE/List/72/0/0/ https://www.duo-shop.de/de-DE/List/73/0/0/ https://www.duo-shop.de/de-DE/List/9/0/0/ https://www.duo-shop.de/de-DE/List/690/0/0/ https://www.duo-shop.de/de-DE/List/329/0/0/ https://www.duo-shop.de/de-DE/List/537/0/0/ Task : Get EAN number and associated price for each EAN number. Output : Spreadsheet(or CSV) with EAN and price columns. Separate file for each product category. We begin by investigating the website to be scraped from. It's a german e-commerce website selling wide range of product(product type doesn't matter for what we're trying to achieve here). All product listing follow html structure, so if we can get information of one EAN, we can

Building a local weather station using Raspberry pi W and Arduino Nano || Serial communication over Bluetooth HC-05 module

Image
  So this DIY Weather Station involves a few different Hardware modules and a little bit of programming. The idea is, to display the weather status, temperature and humidity levels on a LCD Display that gets updated on a hourly basis. Our Raspberry pi W is going to host the programs and is responsible for sending the correct data from the internet to the Arduino Nano over a Serial communication. We'll make use of the bluetooth module to connect to the bluetooth capabilities of pi to send the data over to the display unit. Things required : Raspberry Pi Zero W x 1 Arduino Nano x 1 LCD 1602 Display x 1 I2C module x 1 Bluetooth HC-05 module x 1 Jumper wires for making connections 5V power source for both raspberry pi and arduino nano (we can power other modules from nano board) Setup Arduino Nano Our LCD Display Module can be connected to Arduino nano in two ways, with or without I2C module. Without it, we'll need to connect 8 pins to the Arduino which is tedious and time consumin

Building a news app in react-native using Expo and Express on the Node.js server

Image
The blog post is divided into two sections, in first we will explore creating a basic server for our application. This server uses basic web scraping techniques to retrieve data from a trusted news portal. We are only scraping article title and article link, but can expand feature to include more data as well. In the next section, we will create an a cross-platform app from scratch for both iOS and Android. This app is going to retrieve the data from the server we created in Section 1 and display to the user. Section 1 Building a server : npm install --save express request-promise cheerio Add these dependencies to a new file newsAPI.js. const express = require("express"); const app = express(); const rp = require("request-promise"); const $ = require("cheerio"); app.use(express.json()); app.get("/", (req, res) => {   res.send("Hello !!!"); }); const port = process.env.PORT || 3000; app.listen(port, () => console.log(`http://localh

Youtube not working in Vianet NetTV? Here's how you can fix it

 All Vianet users are aware that Youtube doesn't work in NetTV STB box provided by Vianet. The box is basically an Android OS 6.0 flashed with NetTV image, which means if you can access Play Store you should be able to install Youtube Android app and use it normally. Also, the method described here doesn't impact your regular nettv usage since you can go back to watching TV channels anytime. Items required : USB Keyboard and/or USB Mouse Google account (the one in your android phone if available) NetTV STB box setup connected to a TV display Steps : Unplug your ethernet cable. You'll instead connect to WiFi. Plug in your keyboard to the box and make sure it is turned on. Navigate to Settings and then Network. Select Wireless and connect to your home wifi as you would connect on a smartphone. Go back to home screen and on your Keyboard, press Windows Key( Win ) + B . This will open android browser. Navigate to  https://play.google.com/store/apps  and login using your google

Moving codebase from one git repository to other

Ever since github opened private repository feature to general user, all the developers have been moving their project repo to github. I myself too jumped on the bandwagon recently, and started putting up old projects as well as unfinished ones(there's a lot of those) as private repos in github. I had been taking shelter under gitlab and bitbucket as a backup place for them, but decided it was time to move them to github once and for all. Steps : 1. First I pulled the projects off of the old repo, using the following line :     git clone <git-project-url from old repo> 2. After getting inside the project directory, I used the following command to point it to my newly created repo in github.     git remote set-url origin <git-project-url from github> 3. I entered the following to confirm the change worked.     git remote -v Now, if you didn't have a README.md file on the previous repo, but github created one for you when you created the repo, this is going to create

Publishing your first app built using Expo to Android Play Store and iOS App Store without using a Mac hardware

This sounds like what a lot of beginner developers need right now. You make an app and you want it to be available to users instantly without having to distribute using pesky installation files or google drive links. Also, when you start out on Expo, you hear a lot of 'cross-platform' keywords being thrown around, and that's what brought you to Expo in the first place. Now that you're ready to start sharing, you need help publishing it to the stores and making it instantly ready, so you can focus on other things such as marketing, testing, feature upgrade and so on. This guide attempts to piece together what you'd need to for publishing your app to both android and ios store. And yes, you don't necessarily need a MacOS hardware for publishing to iOS App store. Once you're ready with making all changes, you're ready to build the production version. Pre-requisites Firstly, update the version code in your app.json file. This is done so that each time you up

Enabling auto login feature in Windows

Autologin is not provided default by Windows. As a security measure, Windows wants you to keep a password login(PIN, password, fingerprint, picture, text etc) feature, but sometimes you'd want it to startup automatically for variety of reasons. A logged in system can be used with variety of startup applications, Kiosk interfaces, or even Remote Access feature such as VNC. It lets you make a cleaner setup out of your Windows machine. Also, if you aren't a Linux user, you will be able to setup home server in Windows machine after enabling autologin feature. Side note : You don't need autologin feature in Linux in order to use the machine as a server. The straightforward way to setup autologin is to keep a single account in the machine and disable password. However, you cannot leave your machine at the mercy of unauthorized access with this option. So, the recommended method is to setup an Administrator account with password, and setup auto login with a standard user. But t

Exposing VMware linux server image's IP address to local area connection

Recently, we decided to move our SOHO RHEL server at office to a more permanent location. After powering it on in its new location, we discovered the network was not working. We used to log in to a static IP address of the device using ssh via PuTTY from our laptops to get into the server environment. We hadn't started doing a port configuration system yet, so it must have been something within the physical machine itself. When I joined the team the entire thing was already setup so I hadn't got a chance to look at how we were working with it so far, and this was an opportunity for me to go and take a look at it. Here's how we were using our server. A RedHat Linux Server Disk Image file running on VMWare Pro installed on a Windows 10 machine. First I thought it was a disk image issue and removed all image and configuration files from VMWare. After re-adding the disk image file the system booted perfectly but we weren't getting the previous static IP address as bef

Developing a Twitter bot that lets me watch Youtube videos on random!

I have been getting back to building bots. I think bots are beautiful. Bots are the future. I just finished watching Altered Carbon first Season on Netflix and the Matrix-like world reminded me of how close we are to AI taking over. But I am getting ahead of myself. Check this out: Javi Reina - Alex Guerrero feat. Syntheticsax - Oig 2010 https://t.co/Jczom6C5L9 @sndpwrites #nWriter — nWriter (@nWriterdotcom) April 16, 2018 This post is going to be a part of a series of things I am working on with my bot. I'm having fun. My bot is listening to mentions at @nWriterdotcom. Currently I am filtering out any other tweets that do not have the hashtag ( #youtubeme ) so I can identify different sources of automated tweets(There's a lot).  Right now my bot does this : 1. Listen to mentions containing hashtag #youtubeme 2. Collect public username of source twitter account 3. Generate a random youtube video link with its full information. 4. Bundle it all together into on

Working with string manipulation and basic file io operations in Python

Image
Last night, this tweet appeared in my timeline and caught my attention. The word "friends" is said in every episode of Friends. — Fact (@Fact) March 9, 2018 This doesn't sound right. There was no possible way to verify this and I expressed my concern over the same. A friend suggested counting the word in subtitle file for all episodes. I liked the idea, and a small weekend project was born. Before I give the spoilers away on whether or not it is true, I want to first clarify a few different things on how I got it done. I didn't have the subtitles file so I had to download them all before parsing the word "friends". I began by looking at websites that would let me download the english subtitle files the easiest way possible. Originally I had planned to use urllib   with BeautifulSoup to download the files but TV Subtitles made it really easy for me(kudos to the site developers btw). They let you download seasonwise bulk zip files of all episodes

Top 6 things to do after installing Ubuntu and also save laptop battery life

I have frequently heard complaints about how Ubuntu is draining battery life of their laptop. While this doesn't happen in all the machines, it has happened to mine and I have had to search the internet to fix them. I have put together a list of a few things to do after a fresh installation of Ubuntu x.x. Not all steps mentioned below are required for conserving battery life, but they made sense when talking about a fresh installation of Ubuntu. 1. Get rid of Unity Desktop Environments are a integral part of your OS. They need to serve as good aesthetics in terms of design as well as a stable backend application. Unity is neither. You are better off with Gnome . Or, if your system needs to handle power-friendly DE, go for XFCE . I use i3 desktop manager but I wouldn't recommend it unless you have already used Linux for a while and are familiar with all the terminal commands. First remove Unity. sudo apt-get remove unity unity-2d unity-2d-panel unity-2d-spread unity-asset