November 27, 2023
Unveiling the Powerhouse: Redmi's Latest Sensation - Redmi 12 5G
In the ever-evolving landscape of smartphones, Redmi continues to redefine excellence with its newest addition to the family, the Redmi 12 5G. Packed with cutting-edge features and innovative technology, this device promises an unparalleled user experience that transcends expectations.
Performance Redefined: Snapdragon 4 Gen 2 Mobile Platform
At the heart of the Redmi 12 5G lies the Snapdragon 4 Gen 2 Mobile Platform, boasting a power-efficient 4nm architecture. This ensures not just impressive performance but also remarkable energy efficiency, enabling seamless multitasking and enhancing overall device longevity.
A Visual Treat: Immersive Display and Camera Capabilities
The phone's expansive 17.24cm FHD+ display with a dynamic 90Hz AdaptiveSync refresh rate offers a visual extravaganza. Protected by Corning Gorilla Glass 3, this display promises durability without compromising on stunning visuals.
Capturing life's moments in vivid detail is made effortless with the 50MP f/1.8 AI Dual camera setup. From classic film filters to the brilliance of Portrait and Night Modes, alongside the versatility of Google Lens integration and Time-lapse, this camera system provides a myriad of options for photography enthusiasts. Not to mention the dedicated 50MP mode, delivering breathtaking high-resolution shots. Complementing this, an 8MP front-facing camera ensures selfies are equally impressive.
Sustained Power: Battery and Charging
With a robust 5000mAh(typ) battery capacity, the Redmi 12 5G promises prolonged usage without the worry of running out of power midway through the day. Additionally, the included 22.5W charger ensures rapid charging, minimizing downtime and keeping you on the move.
Smart Features and Resilience
The device comes equipped with MIUI 14 running on Android 13, delivering a seamless and intuitive user interface. Practical features such as the side fingerprint sensor, IR blaster, and the timeless 3.5mm audio jack are thoughtfully integrated. Moreover, its IP53 rating offers a level of protection against dust and water, ensuring durability in various environments.
In conclusion, the Redmi 12 5G encapsulates the essence of innovation and functionality, catering to the diverse needs of modern-day smartphone users. Whether it's the powerhouse performance, captivating camera capabilities, enduring battery life, or robust features, this device stands as a testament to Redmi's commitment to pushing boundaries and delivering exceptional technology to its users.
Click to buy - https://amzn.to/3RiHvrC
April 09, 2015
Installing a storage area network (SAN) on Ubuntu 14.04 LTS
A storage area network is implemented to access storage device from a remote machine in a way that it appears to be locally attached. This is implemented using Small Computer System Interface (SCSI).
A storage area network consists of:
1. Initiator (client)
2. Target (server)
Installation instructions:
Switch to super user. Use command: sudo -i or else use su root
sudo -i
A. Target installation on Ubuntu:
1. Install iscsitarget (iSCSI: Internet Small Computer System Interface)
apt-get install iscsitarget
Checkout: http://iscsitarget.sourceforge.net/
2. Create a logical unit for storing data
dd if=/dev/zero of=/root/lun0 bs=1M count=1024
(lun: logical unit number)
We are creating a 1GB file (/root/lun0) for storing data on SAN.
Run "man dd" for more information on dd command.
3. Enable iscsitarget by editing /etc/default/iscsitarget and setting ISCSITARGET_ENABLE to 'true'.
ISCSITARGET_ENABLE=true
4. Configure ISCSI by editing file: /etc/iet/ietd.conf
Target iqn.2014-04.localhost:target0 Lun 0 Path=/root/lun0,Type=fileio initiator-address 127.0.0.1
Check screenshot for reference.
5. Restart iscsitarget /etc/init.d/iscsitarget (start|stop|restart|...)
/etc/init.d/iscsitarget restart
B. Initiator configuration on Ubuntu:
iscsiadmn -m discovery -p 127.0.0.1 -t st
Run 'man iscsiadmn' for more information on arguments.
iscsiadm --mode node --login --portal 127.0.0.1:3260 --target="iqn.2014-04.localhost:target0"
Replace /dev/sdX with your virtual disk which is like /dev/sdb in our case.
sudo fdisk /dev/sdx
n
p
<enter>
w
n (add new partition table)
p (primary partition)
<enter> (enter, enter, enter for default values)
w (write table and exit)
Check screenshot for reference.
6. Format and make a new file system using mkfs on first partition of the virtual disk (/dev/sdX1)
mkfs.ext4 /dev/sdX1
7. Mount the new partition for use:
mkdir /root/san
mount /dev/sdX1 /root/san
Check back on "Disks" utility. Your storage area network drive should be ready for use.
January 19, 2015
Image processing using MagickCore
App description:
C++ Program with GUI to capture using remotely placed camera and read uncompressed TIFF Image to perform following functions (Menu Driven) Use of Overloading and Morphism is expected. Image Frame1 is used for displaying Original Image and Image Frame 2 is used for displaying the action performed.
• Sharpen the Image
• Convolution(overloading: FFT,Other)
• Blur the Image (Programmable rectangular Seed)
• Programmable image Contrast and Brightness
• Histogram
• Mean and Standard Deviation of image
• Rotate image by programmable angle
Some screenshots:








Frameworks and libs used:
http://www.gtk.org/
http://www.imagemagick.org/script/magick-core.php
August 19, 2014
Automating menial Browser activity using Selenium
Here's a small snippet that I put together for myself just to try out selenium's python bindings. Yes, python is the language of my choice currently! :) Selenium binds of various languages are available on their official website at : http://www.seleniumhq.org/
What this script does is open a third party website: way2sms.com, log me in using my username, password and then send a message to any number of my choice. All of this is done programmatically! So all I've to do is fire up a console and enter my username, password, a mobile number and a message and selenium will handle the rest. Of course, this is just an example and one can use this to perform a variety of tasks, boring or otherwise.
from selenium import webdriver from selenium.webdriver.common.keys import Keys from datetime import datetime def send(username, password, mobile, message): driver = webdriver.Firefox() driver.get("http://site25.way2sms.com/content/index.html") driver.find_element_by_id("username").send_keys(username) driver.find_element_by_id("password").send_keys(password) driver.find_element_by_id("loginBTN").send_keys(Keys.RETURN) driver.execute_script("goToMain('s')") driver.execute_script("loadSMSPage('sendSMS')") frame = driver.find_element_by_id("frame") driver.switch_to_frame(frame) driver.find_element_by_id("mobile").send_keys(mobile) driver.find_element_by_id("message").send_keys(message) driver.find_element_by_id("Send").send_keys(Keys.RETURN) driver.switch_to_default_content() driver.close()
You can install selenium python binding using:
sudo easy_install selenium
Since I hacked this together in hurry, it doesn't include any comments but the code should be self explanatory and easy to follow because all it does is find a web element (like an input box or a button) and send it a sequence of keys ( string value of action keys like RETURN ).
Automating tasks on a third party website requires a bit of inspection of web elements and javascripts, even stylesheet at times. This can be done using built-in web inspectors available with most of the modern browsers like Chrome, Firefox. As of now Firebug is the inspector of my choice.
Keep automating!
August 10, 2014
Write a python program for creating virtual file system on Linux environment.
# Developer: Manish Raj (technoslab@gmail.com) import shelve, time, sys class File(object): def __init__(self, name, type, parent=None, text=''): self.list = [] self.name = name self.type = type self.time = int(time.time()) self.parent = parent self.text = text def is_file(self, name): for node in self.list: if node.name == name: return True return False def is_dir(self, name): if(self.is_file(name)) and self.get(name).type == 'dir': return True return False def get(self, name): for node in self.list: if node.name == name: return node def add(self, name, type, text=''): self.list.append(File(name, type, self, text)) def remove(self, name): self.list.remove(self.get(name)) def rename(self, name): self.name = name def copy(self, src, dest): src = self.get(src) self.add(dest, src.type, src.text) def stat(self): print 'Listing', self.name for node in self.list: print 'Name:', node.name, '; Created:', node.time, '; Type:', node.type def read(self): print 'Reading file:', self.name print self.text class FileSystem(object): COMMANDS = ['ls', 'mkdir', 'chdir', 'cd', 'rmdir', 'create', 'read', 'rm', 'mv', 'cp', 'help', 'exit'] def __init__(self): self.io = shelve.open('file.sys', writeback=True) if self.io.has_key('fs'): self.root = self.io['fs'] else: self.root = File('/', 'dir') self.curr = self.root def mkdir(self, cmd): if len(cmd) < 2 or cmd[1] == '': print 'mkdir - make directory' print 'usage: mkdir <dir_name>' else: name = cmd[1] if self.curr.is_file(name) == False: self.curr.add(name, 'dir') else: print name, ' - already exists.'; def chdir(self, cmd): if len(cmd) < 2 or cmd[1] == '': print 'chdir - change directory.' print 'usage: chdir <dir_name>' else: name = cmd[1] if name == '..': if self.curr.parent is not None: self.curr = self.curr.parent elif self.curr.is_dir(name): self.curr = self.curr.get(name) else: print name, ' - invalid directory.' def rmdir(self, cmd): if len(cmd) < 2 or cmd[1] == '': print 'rmdir - remove directory' print 'usage: rmdir <dir_name>' else: name = cmd[1] if self.curr.is_dir(name): self.curr.remove(name) print 'Directory deleted.' else: print name, ' - invalid directory.' def rm(self, cmd): if len(cmd) < 2 or cmd[1] == '': print 'rm - remove file' print 'usage: rm <file_name>' else: name = cmd[1] if self.curr.is_file(name) and not self.curr.is_dir(name): self.curr.remove(name) print 'File deleted.' else: print name, ' - invalid file.' def ls(self, cmd): if(len(cmd) > 1): print 'ls - list stats' print 'usage: ls' self.curr.stat() def create(self, cmd): if len(cmd) < 2 or cmd[1] == '': print 'create - create a file' print 'usage: create <file_name>' else: name = cmd[1] self.curr.add(name, 'file', raw_input('Enter file context: ')) def read(self, cmd): if len(cmd) < 2 or cmd[1] == '': print 'read - read a file' print 'usage: read <file_name>' else: name = cmd[1] if self.curr.is_file(name): self.curr.get(name).read() else: print name, 'invalid file' def mv(self, cmd): if len(cmd) < 3 or cmd[1] == '': print 'mv - rename a file' print 'usage: mv <old_name> <new_name>' else: old_name = cmd[1] new_name = cmd[2] if self.curr.is_file(old_name): self.curr.get(old_name).rename(new_name) else: print old_name, 'invalid file' def cp(self, cmd): if len(cmd) < 3 or cmd[1] == '': print 'cp - copy a file' print 'usage: cp <src> <dest>' else: src = cmd[1] dest = cmd[2] if self.curr.is_file(src): self.curr.copy(src, dest) else: print src, 'invalid file' def save(self): self.io['fs'] = self.root self.io.sync() def help(self, cmd): print 'COMMANDS: mkdir, ls, chdir, rmdir, create, read, mv, cp, rm, exit' def exit(self, cmd): sys.exit(0) def main(): fs = FileSystem() while True: cmd = raw_input('> ').split(' '); method = None try: method = getattr(fs, cmd[0]) except AttributeError: print 'Invalid command. Type "help".' if method is not None and cmd[0] in FileSystem.COMMANDS and callable(method): method(cmd) fs.save() else: print 'Invalid command. Type "help".' main()
August 07, 2014
Capture/Record webcam, desktop and audio under Ubuntu 14.04

Bash script:
fname=`date +"%d.%m.%Y_%H:%M:%S_%P"`.'_screencast.mp4' vlc --qt-minimal-view v4l2:///dev/video0 & vlc --qt-minimal-view screen:// :screen-fps=20 :screen-follow-mouse :live-caching=300 :input-slave=alsa://hw:0,0 :sout="#transcode{vcodec=h264,vb=384,fps=5,acodec=mpga}:duplicate{dst=std{mux=mp4,access=file,dst='$fname'}}" &
These set of commands start two instances of VLC.
The first command fires up a minimal view of VLC with video source "/dev/video0" (the default location of webcamera in most general cases).
The second command starts another minimal VLC instance with video from screen:// (desktop) and audio from default built-in microphone "hw:0,0". Output is encoded and saved in current directory as an mp4 file.
Recording stops when you close VLC instances.
February 09, 2014
OOMP Assignment#4
Aim: Design a C++ Class "Complex" with data members for real and imaginary part. Provide
default and parametrized constructors. Write a program to perform arithmetic operations
of two complex numbers using operator overloading (using either member functions or
friend functions).
*/
#include <iostream>
#include <math.h>
using namespace std;
class Complex{
public:
int a;
int b;
Complex(){
Complex(0, 0);
}
Complex(int x, int y){
a = x;
b = y;
}
void get(){
cout << endl << "Enter real part: ";
cin >> a;
cout << endl << "Enter imaginary part: ";
cin >> b;
print();
}
void print(){
cout << endl << a << " " << (b >= 0 ? "+" : "-") << " " << abs(b) << "i";
}
Complex operator + (Complex c){
return Complex(a + c.a, b + c.b);
}
Complex operator - (Complex c){
return Complex(a - c.a, b - c.b);
}
Complex operator *(Complex c){
return Complex(a * c.a - b * c.b, a*c.b + c.a * b);
}
Complex operator /(Complex c){
return Complex((a * c.a + b * c.b)/(c.a * c.a + c.b * c.b), (b * c.a - a * c.b)/(c.a * c.a + c.b * c.b));
}
};
int main(){
int choice;
Complex c1, c2, c3;
do{
cout << endl << "-- Complex Numbers --";
cout << endl << "1. Input numbers";
cout << endl << "2. Display numbers";
cout << endl << "3. Add";
cout << endl << "4. Subtract";
cout << endl << "5. Multiply";
cout << endl << "6. Divide";
cout << endl << "7. Exit";
cout << endl << "Enter your choice: ";
cin >> choice;
switch(choice){
case 1 : c1.get(); c2.get(); break;
case 2 : c1.print(); c2.print(); break;
case 3 :
c3 = c1 + c2;
cout << endl << "Result of addition: ";
c3.print();
break;
case 4 :
c3 = c1 - c2;
cout << endl << "Result of subtraction: ";
c3.print();
break;
case 5 :
c3 = c1 * c2;
cout << endl << "Result of multiplication: ";
c3.print();
break;
case 6 :
c3 = c1 / c2;
cout << endl << "Result of division: ";
c3.print();
break;
default : cout << endl << "Invalid choice!"; break;
}
}while(choice != 7);
return 0;
}
/*
---------------------------------------
OUTPUT
---------------------------------------
-- Complex Numbers --
1. Input numbers
2. Display numbers
3. Add
4. Subtract
5. Multiply
6. Divide
7. Exit
Enter your choice: 1
Enter real part: 10
Enter imaginary part: 20
10 + 20i
Enter real part: -15
Enter imaginary part: -25
-15 - 25i
-- Complex Numbers --
1. Input numbers
2. Display numbers
3. Add
4. Subtract
5. Multiply
6. Divide
7. Exit
Enter your choice: 2
10 + 20i
-15 - 25i
-- Complex Numbers --
1. Input numbers
2. Display numbers
3. Add
4. Subtract
5. Multiply
6. Divide
7. Exit
Enter your choice: 3
Result of addition:
-5 - 5i
-- Complex Numbers --
1. Input numbers
2. Display numbers
3. Add
4. Subtract
5. Multiply
6. Divide
7. Exit
Enter your choice: 4
Result of subtraction:
25 + 45i
-- Complex Numbers --
1. Input numbers
2. Display numbers
3. Add
4. Subtract
5. Multiply
6. Divide
7. Exit
Enter your choice: 5
Result of multiplication:
350 - 550i
-- Complex Numbers --
1. Input numbers
2. Display numbers
3. Add
4. Subtract
5. Multiply
6. Divide
7. Exit
Enter your choice: 6
Result of division:
0 + 0i
-- Complex Numbers --
1. Input numbers
2. Display numbers
3. Add
4. Subtract
5. Multiply
6. Divide
7. Exit
Enter your choice: 7
*/
OOMP Assignment#3
Aim: Develop an object oriented program in C++ to create a database of the personnel
information system containing the following information: Name, Date of Birth, Blood
group, Height, Weight, Insurance Policy, number, Contact address, telephone number,
driving license no. etc Construct the database with suitable member functions for
initializing and destroying the data viz constructor, default constructor, copy, constructor,
destructor, static member functions, friend class, this pointer, inline code and dynamic
memory allocation operators-new and delete.
*/
#include <iostream>
#define MAX_RECORDS 50
using namespace std;
class Information{
friend class Records;
private:
string name, dateOfBirth, bloodGroup, contactAddress;
float height, weight;
double policyNumber, telephoneNumber, licenseNumber;
public:
Information(string n, string dob, string bg, string ca, int h, int w, double pn, double tn, double ln){
this->name = string(n);
this->dateOfBirth = string(dob);
this->bloodGroup = string(bg);
this->contactAddress = string(ca);
this->height = h;
this->weight = w;
this->policyNumber = pn;
this->telephoneNumber = tn;
this->licenseNumber = ln;
}
Information(){
Information("", "", "", "", 0, 0, 0, 0, 0);
}
Information(const Information& otherInfo){
this->name = otherInfo.name;
this->dateOfBirth = otherInfo.dateOfBirth;
this->bloodGroup = otherInfo.bloodGroup;
this->contactAddress = otherInfo.contactAddress;
this->height = otherInfo.height;
this->weight = otherInfo.weight;
this->policyNumber = otherInfo.policyNumber;
this->telephoneNumber = otherInfo.telephoneNumber;
this->licenseNumber = otherInfo.licenseNumber;
}
inline void acceptValues(){
cout << endl << "Enter personal details: ";
cout << endl << "Name: ";
cin >> this->name;
cout << endl << "Date Of Birth: ";
cin >> this->dateOfBirth;
cout << endl << "Blood Group: ";
cin >> this->bloodGroup;
cout << endl << "Contact Address: ";
cin >> this->contactAddress;
cout << endl << "Height: ";
cin >> this->height;
cout << endl << "Weight: ";
cin >> this->weight;
cout << endl << "Policy Number: ";
cin >> this->policyNumber;
cout << endl << "Telephone Number: ";
cin >> this->telephoneNumber;
cout << endl << "License Number: ";
cin >> this->licenseNumber;
}
inline void display(){
cout << endl << "Personal details: " << endl;
cout << endl << "Name: " << this->name;
cout << endl << "Date Of Birth: " << this->dateOfBirth;
cout << endl << "Blood Group: " << this->bloodGroup;
cout << endl << "Contact Address: " << this->contactAddress;
cout << endl << "Height: " << this->height;
cout << endl << "Weight: " << this->weight;
cout << endl << "Policy Number: " << this->policyNumber;
cout << endl << "Telephone Number: " << this->telephoneNumber;
cout << endl << "License Number: " << this->licenseNumber << endl;
}
};
class Records{
private:
Information * records[MAX_RECORDS];
public:
static int COUNT;
static int getCount(){
return COUNT;
}
static void incCount(){
COUNT++;
}
void add(){
records[Records::getCount()] = new Information();
records[Records::getCount()]->acceptValues();
Records::incCount();
}
void display(){
for(int i = 0; i < Records::getCount(); i++){
records[i]->display();
}
}
~Records(){
for(int i = 0; i < Records::getCount(); i++){
delete records[i];
}
}
};
int Records::COUNT = 0;
int main(){
int choice;
Records * rs = new Records();
do{
cout << endl << "-- Personal Information --";
cout << endl << "1. Add information";
cout << endl << "2. Display information";
cout << endl << "3. Exit";
cout << endl << "Your choice: ";
cin >> choice;
switch(choice){
case 1 : rs->add(); break;
case 2 : rs->display(); break;
}
}while(choice != 3);
delete rs;
return 0;
}
/*
---------------------------------------
OUTPUT
---------------------------------------
-- Personal Information --
1. Add information
2. Display information
3. Exit
Your choice: 1
Enter personal details:
Name: Man
Date Of Birth: 4/4/1994
Blood Group: O+
Contact Address: Pune
Height: 160
Weight: 65
Policy Number: 7766554433
Telephone Number: 9988776655
License Number: 123456890
-- Personal Information --
1. Add information
2. Display information
3. Exit
Your choice: 1
Enter personal details:
Name: Tau
Date Of Birth: 5/5/1995
Blood Group: AB-
Contact Address: Mumbai
Height: 160
Weight: 45
Policy Number: 1234554321
Telephone Number: 9988006677
License Number: 0987654321
-- Personal Information --
1. Add information
2. Display information
3. Exit
Your choice: 2
Personal details:
Name: Man
Date Of Birth: 4/4/1994
Blood Group: O+
Contact Address: Pune
Height: 160
Weight: 65
Policy Number: 7.76655e+009
Telephone Number: 9.98878e+009
License Number: 1.23457e+008
Personal details:
Name: Tau
Date Of Birth: 5/5/1995
Blood Group: AB-
Contact Address: Mumbai
Height: 160
Weight: 45
Policy Number: 1.23455e+009
Telephone Number: 9.98801e+009
License Number: 9.87654e+008
-- Personal Information --
1. Add information
2. Display information
3. Exit
Your choice: 3
*/
OOMP Assignment#2
Aim: A book shop maintains the inventory of books that are being sold at the shop. The list includes details such as author, title, price, publisher and stock position. Whenever a
customer wants a book, the sales person inputs the title and author and the system
searches the list and displays whether it is available or not. If it is not, an appropriate
message is displayed. If it is, then the system displays the book details and requests
for the number of copies required. If the requested copies book details and requests
for the number of copies required. If the requested copies are available, the total cost
of the requested copies is displayed; otherwise the message "Required copies not in
stock" is displayed. Design a system using a class called books with suitable member functions and
Constructors. Use new operator in constructors to allocate memory space required.
Implement C++ program for the system.
*/
#include <iostream>
#include <string.h>
#define MAX_BOOKS 50
using namespace std;
class Book{
friend class BookShop;
string author;
string title;
string publisher;
int stockPosition;
float price;
public:
Book(){
author = "";
title = "";
publisher = "";
stockPosition = 0;
price = 0;
}
float getPrice(int numOrder){
return price * numOrder;
}
bool isAvailable(int numOrder){
return numOrder <= stockPosition;
}
void printDetails(){
cout << endl << "--- Book details ---";
cout << endl << "Title: " << title;
cout << endl << "Author: " << author;
cout << endl << "Publisher: " << publisher;
cout << endl << "StockPosition: " << stockPosition;
cout << endl << "Price: Rs." << price;
}
void get(){
cout << endl << "Enter new book details: ";
cout << endl << "Title: ";
cin >> title;
cout << endl << "Author: ";
cin >> author;
cout << endl << "Publisher: ";
cin >> publisher;
cout << endl << "Price: ";
cin >> price;
cout << endl << "Stock Position: ";
cin >> stockPosition;
}
void placeOrder(){
int numOrder;
cout << endl << "Enter number of copies: ";
cin >> numOrder;
if(isAvailable(numOrder)){
cout << endl << "Required copies are available in stock. Total price: Rs." << getPrice(numOrder);
}else{
cout << endl << "Required copies not in stock.";
}
}
};
class BookShop{
Book * books[MAX_BOOKS];
int index;
public:
BookShop(){
index = 0;
}
void add(){
books[index] = new Book();
books[index]->get();
index++;
}
void request(){
int choice = 0, search = -1;
cout << endl << "Search for book by: ";
cout << endl << "1) Title";
cout << endl << "2) Author";
cout << endl << "Enter choice: ";
cin >> choice;
switch(choice){
case 1 : search = searchTitle(); break;
case 2 : search = searchAuthor(); break;
default: cout << endl << "Invalid choice!"; break;
}
if(search == -1){
cout << endl << "No results found!";
}else{
cout << endl << "Book found: ";
books[search]->printDetails();
books[search]->placeOrder();
}
}
int searchTitle(){
string title;
cout << endl << "Enter book title to search: ";
cin >> title;
for(int i = 0; i < index; i++){
if(title.compare(books[i]->title) == 0){
return i;
}
}
return -1;
}
int searchAuthor(){
string author;
cout << endl << "Enter author name to search: ";
cin >> author;
for(int i = 0; i < index; i++){
if(author.compare(books[i]->author) == 0){
return i;
}
}
return -1;
}
};
int main(){
int choice;
BookShop * bs = new BookShop();
do{
cout << endl << "-- Book Shop --";
cout << endl << "1. Add book";
cout << endl << "2. Request book";
cout << endl << "3. Exit";
cout << endl << "Your choice: ";
cin >> choice;
switch(choice){
case 1 : bs->add(); break;
case 2 : bs->request(); break;
}
}while(choice != 3);
delete bs;
return 0;
}
/*
---------------------------------------
OUTPUT
---------------------------------------
-- Book Shop --
1. Add book
2. Request book
3. Exit
Your choice: 1
Enter new book details:
Title: Gravity
Author: Rohit
Publisher: GHRCEM
Price: 400
Stock Position: 10
-- Book Shop --
1. Add book
2. Request book
3. Exit
Your choice: 1
Enter new book details:
Title: Inferno
Author: Tauseef
Publisher: GHRCEM
Price: 350
Stock Position: 5
-- Book Shop --
1. Add book
2. Request book
3. Exit
Your choice: 2
Search for book by:
1) Title
2) Author
Enter choice: 1
Enter book title to search: Gravity
Book found:
--- Book details ---
Title: Gravity
Author: Rohit
Publisher: GHRCEM
StockPosition: 10
Price: Rs.400
Enter number of copies: 15
Required copies not in stock.
-- Book Shop --
1. Add book
2. Request book
3. Exit
Your choice: 2
Search for book by:
1) Title
2) Author
Enter choice: 2
Enter author name to search: Tauseef
Book found:
--- Book details ---
Title: Inferno
Author: Tauseef
Publisher: GHRCEM
StockPosition: 5
Price: Rs.350
Enter number of copies: 4
Required copies are available in stock. Total price: Rs.1400
-- Book Shop --
1. Add book
2. Request book
3. Exit
Your choice: 3
*/
January 28, 2014
OOMP Assignment#1
Aim: Create a class named weather report that holds a daily weather report with datamembers day_of_month,hightemp,lowtemp,amount_rain and amount_snow. The
constructor initializes the fields with default values: 99 for day_of_month, 999 for
hightemp,-999 for low emp and 0 for amount_rain and amount_snow. Include a
function that prompts the user and sets values for each field so that you can override
the default values. Write a C++/Java/Python program that creates a monthly report.
*/
#include <iostream>
#include <cmath>
#define MAX_MONTH 12
#define MAX_DAY 30
using namespace std;
class WeatherReport{
public:
int day_of_month, high_temp, low_temp, amount_snow, amount_rain;
WeatherReport(){
day_of_month = 99;
high_temp = 999;
low_temp = -999;
amount_snow = amount_rain = 0;
}
void get(){
cout << endl << "Enter day of month: ";
cin >> day_of_month;
cout << endl << "Enter high temperature: ";
cin >> high_temp;
cout << endl << "Enter low temperature: ";
cin >> low_temp;
cout << endl << "Enter amount of rain: ";
cin >> amount_rain;
cout << endl << "Enter amount of snow: ";
cin >> amount_snow;
}
int format(int number, int digit = 3){
int base = (int) (pow(10.0, digit-1) + 0.5f);
cout << ((number < 0) ? "-" : "+");
number = abs(number);
while(number < base && base > 1){
cout << "0";
base /= 10;
}
return number;
}
void display(){
cout << endl;
cout << format(day_of_month) << "\t";
cout << format(high_temp) << "\t";
cout << format(low_temp) << "\t";
cout << format(amount_rain) << "\t";
cout << format(amount_snow);
}
};
class YearReport{
WeatherReport * wr[MAX_MONTH][MAX_DAY];
int month, day;
public:
YearReport(){
month = day = 0;
for(int i = 0; i < MAX_MONTH; i++){
for(int j = 0; j < MAX_DAY; j++){
wr[i][j] = new WeatherReport();
}
}
}
void getMonth(){
cout << endl << "Enter month: ";
cin >> month;
if(month <= 0 || month > MAX_MONTH){
month = 0;
cout << endl << "Month must be in the range 1 - " << MAX_MONTH;
}
}
void getDay(){
cout << endl << "Enter day: ";
cin >> day;
if(day <= 0 || day > MAX_DAY){
day = 0;
cout << endl << "Day must be in the range 1 - " << MAX_DAY;
}
}
void get(){
getMonth();
getDay();
if(month > 0 && day > 0){
wr[month-1][day-1]->get();
}
}
void display(){
getMonth();
cout << endl << "Day Temp_H Temp_L Rain Snow";
cout << endl << "-------------------------------------";
if(month > 0){
for(int i = 0; i < MAX_DAY; i++){
wr[month-1][i]->display();
}
}
displayAverage();
}
void displayAverage(){
if(month > 0){
float avg_ht = 0, avg_lt = 0, avg_r = 0, avg_s = 0, count = 0;
for(int i = 0; i < MAX_DAY; i++){
if(wr[month-1][i]->day_of_month != 99){
avg_ht += wr[month-1][i]->high_temp;
avg_lt += wr[month-1][i]->low_temp;
avg_s += wr[month-1][i]->amount_snow;
avg_r += wr[month-1][i]->amount_rain;
count += 1;
}
}
if(count != 0){
avg_ht /= count;
avg_lt /= count;
avg_s /= count;
avg_r /= count;
}
cout << endl << "Avg" << endl << " \t" << avg_ht << "\t" << avg_lt << "\t" << avg_r << "\t" << avg_s;
}
}
};
int main(){
int choice;
YearReport * yr = new YearReport();
do{
cout << endl << "-- Weather Report --";
cout << endl << "1. Enter data";
cout << endl << "2. Display Report";
cout << endl << "3. Exit";
cout << endl << "Your choice: ";
cin >> choice;
switch(choice){
case 1 : yr->get(); break;
case 2 : yr->display(); break;
}
}while(choice != 3);
delete yr;
return 0;
}
/*
---------------------------------------
OUTPUT
---------------------------------------
-- Weather Report --
1. Enter data
2. Display Report
3. Exit
Your choice: 1
Enter month: 1
Enter day: 1
Enter day of month: 1
Enter high temperature: 15
Enter low temperature: -10
Enter amount of rain: 20
Enter amount of snow: 10
-- Weather Report --
1. Enter data
2. Display Report
3. Exit
Your choice: 1
Enter month: 1
Enter day: 2
Enter day of month: 2
Enter high temperature: 14
Enter low temperature: -15
Enter amount of rain: 30
Enter amount of snow: 20
-- Weather Report --
1. Enter data
2. Display Report
3. Exit
Your choice: 2
Enter month: 1
Day Temp_H Temp_L Rain Snow
-------------------------------------
+001 +015 -010 +020 +010
+002 +014 -015 +030 +020
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
+099 +999 -999 +000 +000
Avg
14.5 -12.5 25 15
-- Weather Report --
1. Enter data
2. Display Report
3. Exit
Your choice: 3
*/
February 26, 2013
Nokia 105 is a $20 budget phone with great features
Nokia is back to it's root with this amazing budget phone with great features for that price range: $20(lol) they can be used as disposable phones too.
Flashlight, FM, dust and splash proof and comes with a battery that lasts a month.
Check out this video by thenokiablog:
February 24, 2013
7 and 10 inch ultra-portable Android tablets by announced Lenovo
Here's some quick specs:
Lenovo A1000
7 inch display
Android 4.1 JB
1.2GHz dual-core processor
16GB Internal storage
MicroSD slot
Will be available in black and white colors
Lenovo A3000
1.2GHz quad-core MediaTek processor
Android 4.1 JB
7-inch 1024x600p IPS display
MicroSD card slot
Will be available in 3G as well as Wi-Fi only versions
Lenovo S6000
10.1-inch display with 1280x800p resoultion
1.2 GHz quad-core MediaTek processor
Micro HDMI port
Want more? Check this out: http://www.bgr.in/news/lenovo-launches-a1000-a3000-and-s6000-android-tablets-at-mwc/
Samsung Galaxy Note 8.0 specs and hands-on
Weight: 338g
Display: 8 inch
Resolution: 1280 x 800 pixel
Ram: 2GB
Processor: Quad-core Samsung Exynos processor/1.6 GHz( this is awesome )
Internal storage: 16GB/32GB
MicroSD support: Yes
Primary Camera: 5 MP
Secondary camera: 1.2 MP (front-facing)
Check this out for more info and hands on vid: http://www.theverge.com/2013/2/23/4021698/samsung-galaxy-note-8-0-hands-on-preview
February 23, 2013
Java transparent widget
Cool widget in java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.io.File;
import java.net.Socket;
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Scanner;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class Status {
public static void main(String[] args) {
final int w = 130;
final int h = 500;
Dimension x = Toolkit.getDefaultToolkit().getScreenSize();
final JDialog d = new JDialog();
d.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
d.setUndecorated(true);
d.setSize(w, h);
d.setBackground(new Color(0, 0, 0, 0));
d.setBounds(x.width - w - 20, 20, w, h);
d.setAlwaysOnTop(true);
JLabel l = new JLabel();
l.setBackground(new Color(0, 0, 0, 0));
l.setForeground(new Color(255, 255, 255));
try {
l.setFont(Font.createFont(Font.TRUETYPE_FONT, l.getClass().getResourceAsStream("/consola.ttf")).deriveFont(Font.PLAIN, 13));
} catch (Exception e) {
l.setFont(l.getFont().deriveFont(Font.PLAIN, 13));
e.printStackTrace();
}
l.setBorder(javax.swing.BorderFactory.createMatteBorder(5, 0, 0, 0, new Color(255, 255, 255)));
l.setVerticalAlignment(l.TOP);
l.setHorizontalAlignment(l.LEFT);
d.add(l);
d.setVisible(true);
String user = System.getProperty("user.name");
String os = System.getProperty("os.name");
double ram = 0;
try {
Process p = Runtime.getRuntime().exec("wmic OS get TotalVisibleMemorySize /Value");
Scanner scan = new Scanner(p.getInputStream());
while (scan.hasNext()) {
String temp = scan.nextLine();
//System.out.println(temp);
if (temp.startsWith("TotalVisibleMemorySize")) {
ram = Long.parseLong(temp.split("=")[1]);
//System.out.println("RAM :" + ram);
break;
}
}
} catch (Exception e) {
}
d.addMouseMotionListener(new java.awt.event.MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e) {
d.setBounds(e.getXOnScreen(), e.getYOnScreen(), d.getWidth(), d.getHeight());
}
@Override
public void mouseMoved(MouseEvent e) {
}
});
d.addMouseListener(new java.awt.event.MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON2) {
System.exit(0);
}
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
long itime = Calendar.getInstance().getTimeInMillis();
while (true) {
StringBuilder status = new StringBuilder();
status.append("Current user: ").append(user);
status.append("
------------------");
Calendar c = Calendar.getInstance();
status.append("
Time: ").append(c.get(Calendar.HOUR_OF_DAY)).append(":").append(c.get(Calendar.MINUTE)).append(":").append(c.get(Calendar.SECOND));
status.append("
Date: ").append(c.get(Calendar.DATE)).append("/").append(c.get(Calendar.MONTH) + 1).append("/").append(c.get(Calendar.YEAR));
status.append("
------------------");
status.append("
OS: " + os);
status.append("
Memory: ").append(new DecimalFormat("#.##").format(ram / 1024 / 1024)).append(" GB");
status.append("
------------------");
File[] f = File.listRoots();
long total = 0;
long free = 0;
for (int i = 0; i < f.length; i++) {
total = f[i].getTotalSpace();
free = f[i].getFreeSpace();
if (total > 0) {
long p = (free * 100 / total);
status.append("
").append(f[i].getAbsolutePath().replace(File.separator, "")).append(" ").append(total / 1024 / 1024 / 1024).append(" GB");
status.append("
").append(p).append("% free : ").append(free / 1024 / 1024 / 1024).append(" GB");
}
}
status.append("
------------------");
try {
Socket s = new Socket("www.google.com", 80);
s.getInputStream();
s.setSoTimeout(500);
s.close();
status.append("
Internet: On");
} catch (Exception e) {
status.append("
Internet: Off");
}
status.append("
Uptime: ").append((c.getTimeInMillis() - itime) / 1000).append(" s");
status.append("
------------------");
//status.append("
Geek.Manish");
status.append("");
l.setText(status.toString());
try {
Thread.sleep(1000);
} catch (Exception e) {
}
}
}
}

















