C++ Program to tweet

It’s very interesting to play with C++ and if it is in GNU/Linux, lots of tools like ‘wget’, ‘grep’,etc. are there to help us in time. Here is a simple C++ snippet which tweets directly to your time line. Feel free to add more features and would be great if you could share it with me too 🙂

/*
 *      shell-tweet.cpp
 *
 *      Copyright 2009 Ershad K  ershad92@gmail.com
 *      Licensed under GPL Version 3
 *
 *      Please change USERNAME, PASSWORD and compile with g++
 *      To compile - g++ shell-tweet.cpp
 *      To execute - ./a.out
 */

#include <iostream>
#include <string.h>
#include <stdlib.h>

using namespace std;

int main()
{
char name[] = “username”, password[] = “password”, status[500], cmd[500];

char sym[] = {char(34),”};

again: cout << “\n Status: “;
fgets (status,140,stdin);

cout << “\n Length = ” << strlen(status);

if (strlen(status) > 139)
{
cout << ” Exceeds 140 character limit, Type again \n”;
goto again;
}
else
{

strcpy(cmd,”wget -nv –keep-session-cookies –http-user=”);

strcat(cmd,name);
strcat(cmd,” –http-password=”);
strcat(cmd,password);
strcat(cmd,” –post-data=”);
strcat(cmd,sym);
strcat(cmd,”status=”);
strcat(cmd,status);
strcat(cmd,sym);
strcat(cmd,” http://twitter.com:80/statuses/update.xml&#8221;);

system(cmd);

cout << “\n Done”;
}
return 0;
}

Easy Clarity – Connect Easily!

‘Disconnection’ is a routine process in dial up internet. Here is an C++ snippet which dials BSNL WLL Clarity without asking for password again and again. It automatically closes on disconnection with a beep sound.

/*
 *      easyclarity.cpp
 *
 *      Copyright 2009 Ershad K  ershad92@gmail.com
 *      Licensed under GPL Version 3
 *
 *      Please change USERNAME, PASSWORD and compile with g++
 *      To compile - g++ easyclarity.cpp
 *      To execute - ./a.out
 */

#include <iostream>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int main ()
{
	char username[] = "USERNAME";
	char password[] = "PASSWORD";
	puts("\n EasyClarity - Connect wisely!  www.ershadk.wordpress.com\n\n");
	ofstream myfile;
	system("sudo wvdialconf");
	myfile.open ("/etc/widial.conf");
        myfile << "[Dialer Defaults]\nInit1 = ATZ\nInit2 = ATQ0 V1 E1 S0=0 "
               << "&C1 &D2 +FCLASS=0\nInit3 = at+crm=1;+cmux=1;+cps=33;+cta=0"
               << "\nModem Type = Analog Modem\nISDN = 0\nPhone = #777\nModem"
               << " = /dev/ttyUSB0\nUsername = "<<username<<"\nPassword = "
               <<password<<"\nBaud = 460800\nStupid Mode = 1\nAuto DNS\nCheck"
                <<" Def Route";
	myfile.close();
	system("sudo wvdial");
	cout << "\a";
	return 0;
}

How to connect BSNL Clarity in ubuntu 9.04 ?

Though we have many tools to connect BSNL Clarity in Linux Systems, unfortunately they don’t work in ubuntu 9.04 and in other lastest OS’. Here, i will explain how to get connected with BSNL clarity in ubuntu 9.04.

First, you need to edit the grub and add a line to ubuntu’s kernel. Follow the steps to do that:

sudo gedit /boot/grub/menu.lst

Modify the ubuntu’s boot configuration to like this :

title        Ubuntu 9.04
uuid        b744ea84-c1b7-4519-9223-3bb99103d42f
kernel        /boot/vmlinuz-2.6.28-11-generic root=UUID=b744ea84-c1b7-4519-9223-3bb99103d42f ro quiet splash usbserial.vendor=0x15eb usbserial.product=0x0001
initrd        /boot/initrd.img-2.6.28-11-generic

I simply added  ‘usbserial.vendor=0x15eb usbserial.product=0x0001′ to the kernel.

Next step is to install wvdial. Since the ubuntu 9.04 CD edition doesn’t have wvdial by default, we need to install it manually. Follow the steps to install it :

1. Download this file

2. Extract it in your home directory

3. Give the following commands in terminal

cd wvidal

sudo dpkg -i *.deb

4. Restart the computer

It’s done ! Now you can browse like the older versions of ubuntu by executing Mr.Dipin Krishna’s executable (./bsnlclarity in terminal after copying it in your home directory) . You can get it here. Good Luck 🙂


Checknet V1.0 Alpha (GNU/Linux only)

Checknet is an application developed for slow Internet connection(especially Dial-up) users who likes to turn off monitor while downloading some files from the web. Since the monitor is switched off or else if you are working with some other application, you wouldn’t know whether the download is interrupted by connection erros. This application gives you beep-beep alerts when the connection gets dissconnected or the download is interrupted. You even need not turn your speakers ON for alerts, the alerts are from CPU :).

This programs is working based on the amount of received-data. It wil update the record every 2 seconds, if there is no change in the total recieved data, it just starts giving you alerts.

Checknet was initially created just for my personal use, hence it doesn’t feature a good interface or other extra elements. Feel free to edit it to suit your style.

Thanks to Ragsagar ettan and Sarath ettan 🙂

Click here for the executable fileClick here for the source code

Setting up Malayalam and installing swanalekha in sabayon 4

Though the Sabayon 4 DVD release comes with SCIM , it’s not possible read Malayalam or write using swanalekha by the usual methods. Let’s see how to do it.

Type in terminal:

$sudo bash

#wget http://ershad.freehostia.com/download/AnjaliOldLipi.ttf

#cp AnjaliOldLipi.ttf /user/share/fonts/

Now you can read Malayalam :), To type using swanalekha, do the following :

#wget http://ershad.freehostia.com/download/install-swanalekha.tar.gz

#tar -xvf install-swanalekha.tar.gz

It’s done, Right click the text box, select “SCIM input method” and start typing !!

Select SCIM from right click menu

Unfortunately this is not working in firefox. Please inform me if there is any mistake or bug. Thanks to SMC 🙂

A journey with sabayon…

Think of a wonderful world where you have every basic needs without much difficulty and effort. Quite interesting??  well,  This is what sabayon explains, where you will feel heaven if you are using slow Internet without compromising in quality and support.  A bit confusing ?? we’ll see…

My journey with GNU/Linux  started with gentoo  2 years before, when I had a tough time installing it as dual boot  and of  course, it  ended up in the complete data loss !! My next linux-try was ubuntu 8.04, the one that Jesse had given, was easy to install and use. The next OS’ that i tried was  ubuntu 8.10, ubuntu 9.04, kubuntu 8.10 and fedora. But the problem with all these was they are CDs !! Though they contain all basic softwares and packages, it was a tough job to get additional ones. I had to rely on my slow Dial up connection which would take 15 minutes to download 10 MB!! So the one and only choice was to get a DVD based distro.

For the past few weeks,  I was searching for such a DVD release distro so that the rate of software and package downloads can be minimised considerably. My next step was to find such a disrto. To download nearly 4.5 GB @ 16 kbps speed is obviously a nightmare. Then i thought of taking copy, but the source became a issue. As i don’t have any Linux based magazine’s subscription, it was almost impossible.  But later  i came to know that one my friends has such a subscription and he has a  DVD that contains sabayon 4.

Then the things went pretty fast. The installation of sabayon was easy and without XFCE and games, it consumed nearly 9 GB and  took 44 minutes to complete in my P4 2.6 GHz, 1.2 GB RAM Desktop.  The intial boot soon after the installation was slow and it took around 2 minutes to get the login screen. Even now, it is a wonderful sight for me to see many desktop environments including KDE, GNOME etc.. in sessions menu 🙂

Sabayon 4 has all basic free software and package by default. sabayon is meant for all type of users. The software collection explains this.  Inkscape, GIMP etc… are meant for graphic enthusiasts where GCC, JAVA,Python,etc.. are there for programmers. Like these, sabayom comes with many pretty and useful softwares so that users dont have to spend time searching for them. Well, there are the good sides of sabayon. As always, it has another side which is not serious but which worths mentioning here. In ubuntu and other distros, we can install any software or package by running ‘apt-get install’ in terminal which is not possible in sabayon. Also, sabayon dont support deb/rpm packages by default though the team claims it is not necessory where the internal package manager is more than enough. But it would have been better if  sabayon supports that also. Next issue is that, it doesn’t support malayalam by default where i had to install it manually.

Well, I’m not going more technical because, this is my limit. I should stop here, the rest ie about it’s core,kernel, working, etc… are available over web. Please have a look at it if you are interested. I haven’t read this post twice, so they are chances for grammatical/technical/spelling mistakes. Please point them out. Thank you

e-FLAMES Beta now in GNU/Linux :)

Hello friends,

I’m glad to present the Beta version of e-FLAMES for GNU/Linux before you. Thanks to Jesse, for his valuable header file with  getch() function in GNU/Linux.  I have made minor changes in this version and now, it’s licensed under GPL V3. The  program still has some errors when strings with special characters are given as input. Please help me correct those and make this program bug-free.  I expect to release the final version before the end of this month. Till then, please try this program and give me your valuable comments.

(Click here to download GNU/Linux executable)

Here are the screenshots :

The source code is written in C++ using Geany as IDE. The source code is given below …

/*
*      e-FLAMES.cpp
*
*      Copyright 2009 Ershad K <ershad92@gmail.com>
*
*      This program is free software; you can redistribute it and/or modify
*      it under the terms of the GNU General Public License as published by
*      the Free Software Foundation; either version 2 of the License, or
*      (at your option) any later version.
*
*      This program is distributed in the hope that it will be useful,
*      but WITHOUT ANY WARRANTY; without even the implied warranty of
*      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*      GNU General Public License for more details.
*
*      You should have received a copy of the GNU General Public License
*      along with this program; if not, write to the Free Software
*      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
*      MA 02110-1301, USA.
*/

//Including header files..
#include <iostream>
#include <string.h>
#include <stdlib.h> //for system() function
#include “jesse_conio.h”

char name1[30], name2[30]; //declaring global name variables

using namespace std; // dunno what’s this, please tell me..

void message(); // for general headings and texts

void getnames(); // for names input

void copyright(); //print copyright notice

void changecase( char names[]); //change case function

void removespecial(char name_1[]); //remove spaces

(Click here to view full source) (Click here to download GNU/Linux executable)

This source code can be used in windows also with a few changes in headers and can be succesfully compiled. Please add more features and it would be better if any one works to bring out a GUI version of e-FLAMES. Hope you would like this one and feel free to add your suggestions and opinions as comments. Best Wishes

“e-FLAMES” – my latest C++ project

Hello friends,

I’m back with a new C++ project “e-FLAMES”.  Please don’t expect more, i have just started with C++ (forgot to tell you, I’m studying in +1 CS).  Here the ‘e’ stands for electronic (copied from”‘e-mail” 😉 ) , and you know what the FLAMES game is !!

we should cut similar characters in one:one ratio and count the total number of rest characters and apply them on FLAMES. I did the program in this logic and its screenshot and  source is  like this :

e-flames

#include <iostream.h>
#include <conio.h>
#include <process.h>
#include <stdio.h>
void main()
{
int len1,len2;
char name1[30],name2[30];
/* get the two names to be compared */
starty:cout<<“\n”;
cout<<”    e-FLAMES   V 1.0                          “;
cout<<“\n    —————-“;
cout<<”                  © 2009 Ershad.K   +1 CS, B.E.M.H.S.S”;
cout<<“\n                                        ershad92@gmail.com”;
st:cout<<“\n________________________________________________________________________________”;
cout<<“\n Enter first name  : “;
gets(name1);
cout<<“\n Enter second name : “;
gets(name2);
len1 = strlen(name1);
len2 = strlen(name2); ……….. (click here for full source code) (click here for executable)

While  doing this project, i had no idea of functions and now i’m working on it to bring out a linux version of e-FLAMES using functions. The copyright logo is for fun :).  Is it possible to copyright my program like this ?? Please try this  work and give me comments.  Thank you

First step to blogging !

Hello friends,

      For the past few days, i was searching for a good reason to write a blog. On my way, i met some nice friends and their blogs helped me a lot. You must know some facts before reading my articles, that is i’m niether good at english nor experienced at blogging but i can’t sit idle.

 You might have wondered why i selected a name ” syntax” for this blog (if not, please wonder), that is because i need a name related to computers but the words like “hack”,”hack log” etc. are already taken by my above mentioned friends x-( . But there also  i don’t have a mind to give up, i chose “syntax”,which has  no meaning in this context but it seems heavier than other words !! . So this is a start and i expect your co-operation and motivation. Thanks to all. Best wishes…