Wednesday, August 22, 2012

Web Infrastructure on Cloud





Hey Developers out there, if you are searching for a reliable server to host your applications. Here is a small help for all of you.

1. Cloudbees
2. Jelastic
3. Redhat openshift
4. Google Appengine
5. Amazon EC2

The importance of using a hosting service is that you don't have to worry about managing servers and resources. These hosting services provide autoscaling to your services, of-course there is some cost involved but at-least your services are up and running at all times without any type of congestion.

One can choose on variety of platforms like unix, windows or linux. You can choose if you need any relational DB. Generally My-SQL is present with all the vendors. Amount of disk space, max RAM utilization can be chosen but are generally based on pricing slot selected.

Well established services like redhat openshift, google appengine and amazon ec2, which are the pioneers of the cloud services guarantees 99.999% uptime.

Pricing:
Presence of small as well as big players in the market has led enormous competition. The prices are competitive. Prices are based on amount of computing power utilized by the application. The prices are as low as $0.0139 for small applications and as large as $1.477 per hour for high I/O instances on Amazon EC2.

Some other local services might provide you more competitive pricing yet they might have a lot of hidden charges, also they will not be able to provide you with a guaranteed 99.999% uptime.


Thanks Pratikabu for your insight information and feedback.

Please mention your feedback.

Monday, July 9, 2012

Move Gmail attachments to GoogleDrive

With Google now providing free space on Google Drive, on may want all the Gmail attachments that is gets on his email or that he already have on to Google Drive. This post explains a simple and fairly easy way to do that.

Prerequisites

If you would like to have a similar setup for your Gmail and Google Drive, all you need is a minute. Just follow these easy steps:
  1. Assuming that you are logged in to your Google account, create a copy of this sheet in your Google Docs (now Google Drive).
  2. Go to Gmail create a Label "GoogleDrive" to filter only emails that has attachments. Also, you will need to create a folder in the GoogleDrive with the name "Gmail". Please make sure that the names are correctly spelled.
  3. Open the sheet and you should see a new Gmail menu – click Initialize and grant the necessary permissions. This is your sheet (see source code) and you are not sharing your Google credentials or data with anyone else.
  4. Next go the Gmail menu again and select Run. Close the Google sheet and you are done.

Background Work

Here’s how the program works. The Google sheet will monitor your Gmail mailbox in the background (every two minutes) and as soon as it finds any message that has a label GoogleDrive, it will automatically save all the attachments in that message to the Gmail folder on your actual Google Drive.
Once the basic setup is ready, apply the label GoogleDrive to any of your email messages in Gmail and the attached files should become available in your Drive (both online and offline) in the next few minutes.

Troubleshooting

If you are getting errors like “Service invoked too many times,” you can increase the trigger duration. Open the same sheet in Google Docs, go to Tools – > Script Editor and then choose Resources – > Current Script Triggers. Change the value of Minutes timer from “Every 5 minutes” to say “Every 15 minutes”.
If you would like to stop the script from running in the background, go to the same trigger screen and simple delete the “SendToGoogleDrive” time trigger.

Friday, June 1, 2012

VI Editor: Cheat Sheet

In this post I am giving a cheat sheet of VI editor. I found it very useful, hope everyone finds it useful too.


Quitting
:x Exit saving changes 
:q Exit as long as there have been no changes 
ZZ Exit and save changes if any have been made
:q! Exit and ignore any changes 

Inserting Text
i  Insert before cursor 
I  Insert before line 
a  Append after cursor 
A  Append after line 
o  Open a new line after current line 
O  Open a new line before current line 
r  Replace one character 
R  Replace many characters 

Motion
h  Move left 
j  Move down 
k  Move up 
l  Move right 
w  Move to next word 
W  Move to next blank delimited word 
b  Move to the beginning of the word 
B  Move to the beginning of blank delimted word 
e  Move to the end of the word 
E  Move to the end of Blank delimited word 
(  Move a sentence back 
)  Move a sentence forward 
{  Move a paragraph back 
}  Move a paragraph forward 
0  Move to the begining of the line 
$  Move to the end of the line 
1G  Move to the first line of the file 
G  Move to the last line of the file 
nG  Move to nth line of the file 
:n  Move to nth line of the file 
fc  Move forward to c 
Fc  Move back to c 
H  Move to top of screen 
M  Move to middle of screen 
L  Move to botton of screen 
%  Move to associated ( ),  { }, []

Deleting Text
Almost all deletion commands are performed by typing d followed by a motion. For example,  dw deletes a word. A few other deletes are:
x  Delete character to the right of cursor 
X  Delete character to the left of cursor 
D  Delete to the end of the line 
dd  Delete current line 
:d  Delete current line 


Yanking Text
Like deletion, almost all yank commands are performed by typing y followed by a motion. For example, y$ yanks to the end of the line. Two other yank commands are:
yy  Yank the current line 
:y  Yank the current line 


Putting text
p  Put after the position or after the line 
P  Put before the poition or before the line 

Search for strings
/string  Search forward for string 
?string  Search back for string 
n  Search for next instance of string 
N  Search for previous instance of string 

Replace
The search and replace function is accomplished with the :s command. It is commonly used in combination with ranges or the :g command (below).
:s/pattern/string/flags Replace pattern with string according to flags. 
g Flag Replace all occurences of pattern 
c Flag Confirm replaces
& Repeat last :s command 
:.=  Shows current line number 
:=  Shows number of lines in file 


VI Settings
Note: Options given are default. To change them, enter type :set option to turn them on or :set nooption to turn them off.To make them execute every time you open VI, create a file in your HOME directory called .exrc and type the options without the colon (:) preceding the option Set Default Description
:set ai noai  Turns on auto indentation 
:set all  Prints all options to the screen 
:set ap aw  Prints line after d c J m :s t u commands 
:set aw noaw  Automatic write on :n ! e# ^^ :rew ^} :tag 
:set bf nobf  Discards control characters from input 
:set dir=tmp dir = /tmp  Sets tmp to directory or buffer file 
:set eb noed  Precedes error messages with a bell 
:set ed noed  Precedes error messages with a bell 
:set ic noic  Ignores case when searching 
:set lisp nolisp  Modifies brackets for Lisp compatibility. 
:set list nolist  Shows tabs (^l) and end of line ($) 
:set magic magic  Allows pattern matching with special characters 
:set mesg  mesg  Allows others to send messages 
:set nooption   Turns off option 
:set nu nonu  Shows line numbers 
:set opt opt  Speeds output; eliminates automatic RETURN 
:set prompt prompt  Prompts for command input with : 
:set re nore  Simulates smart terminal on dumb terminal 
:set ro noro  Changes file type to "read only" 
:set scroll=n scroll = 11  set n lines for CTRL-d and z 
:set showmode nosm  Indicates input or replace mode at bottom 
:set sm nosm  Show matching { or ( as ) or } is typed 

Saturday, May 12, 2012

Set Default OS in Fedora 16

This is for dual boot OS users, there are many who prefers dual boot to keep another OS optional. For any reason if you wish to change boot sequence unlike grub, grub2 requires couple of commands to run.

Here will take example to keep Windows as default boot.
First of all find menuentry for Windows

#cat /boot/grub2/grub.cfg |grep Windows
the output will be:

menuentry "Windows 7 (loader) (on /dev/sda1)" --clas-clss window -ass os {

To set Windows menuentry as default (only entry mentioned in either " or ' from above command)
I had problem using doubble quotes in the command line. The problem was resolved when in changed the keyboard type from "US" to "US(Engish)" using


#system-config-keyboard

To set Windows menuentry as default (only entry mentioned in either " or ' from above command)

#grub2-set-default "Windows 7 (loader) (on /dev/sda1)"

Verify default entry

#grub2-editenv list

Generate updated grub.cfg

#grub2-mkconfig -o /boot/grub2/grub.cfg

If you get grub error "Environment block too small" then:
#rm -rf /boot/grub2/grubenv
and then rebuild it using
#grub2-editenv /boot/grub2/grubenv create


Now follow all the above steps.

Friday, May 11, 2012

Linux Run Levels

Linux systems today generally use seven runlevels.

Runlevels define what services or processes should be running on the system.

The init process can run the system in one of seven runlevels. The system runs only one of the eight runlevels at a time.

The main runlevels are from 0 – 6. Here's what each runlevel is for:

Runlevel 0: Halt System - To shutdown the system
Runlevel 1: Single user mode
Runlevel 2: Basic multi user mode without NFS
Runlevel 3: Full multi user mode (text based)
Runlevel 4: unused
Runlevel 5: Multi user mode with Graphical User Interface
Runlevel 6: Reboot System

Runlevels 1 and 2 are generally used for debugging purposed only, and are not used during normal operations. Most desktop linux distributions boot into runlevel 5, which starts up the Graphical Login Prompt. This allows the user to use the system with X-Windows server enabled. Most servers boot into runlevel 3, which starts the text based login prompt.

Linux runlevels can be changed on the fly using the init tool. If you want to switch from text based operations to the Graphical Interface, you just have to type in 'telinit 5' in the root prompt. This will bring up the Graphical Interface in your system.

Each runlevel can be configured by the system administrator. The "/etc/inittab" file has information on which runlevel to start the system at and lists the processes to be run at each runlevel.

Each runlevel has its own directory structure where you can define the order in which the services start. These directories are located in the /etc/rc.d/ directory, under which you have rc1.d, rc2.d, rc3.d…. rc6.d directories where the number from 0 through 6 that corresponds to the runlevel.

Refer to Wiki for runlevels on different Operating Systems.

Friday, May 4, 2012

Windows Tricks: Try out..!!

In order to achieve a faster response while in all programs in the start menu, you can easily change a registry key.

XP Instructions

1. Click the "Start" button.
2. Click "run".
3. Type "regedit" without quotes and click ok.

Note you should now be in the Registry Editor.

4. Open (double click or click the + symbol) HKEY_CURRENT_USER
5. Open (double click or click the + symbol) Control Panel
6. Open (double click or click the + symbol) Desktop
7. In the right panel, find "MenuShowDelay"
8. Right click the row and click "Modify"
9. Change the value of "400" to "0" (without quotes), or whatever you want.
10. Restart your computer.

Vista / Win 7

Same as above.

#################################################

In order to achieve a faster response while in all programs in the start menu, you can easily change a registry key.

XP Instructions

1. Click the "Start" button.
2. Click "run".
3. Type "regedit" without quotes and click ok.

Note you should now be in the Registry Editor.

4. Open (double click or click the + symbol) HKEY_CURRENT_USER
5. Open (double click or click the + symbol) Control Panel
6. Open (double click or click the + symbol) Desktop
7. In the right panel, find "MenuShowDelay"
8. Right click the row and click "Modify"
9. Change the value of "400" to "0" (without quotes), or whatever you want.
10. Restart your computer.

Vista / Win 7

Same as above.

Tuesday, May 1, 2012

Botnet

"A Botnet is a collection of software agents, or robots, that run autonomously and automatically. The term is most commonly associated with malicious software, but it can also refer to a network of computers using distributed computing software."

It all starts out with the creator of the botnet, the herder. A herder is the (master)mind behind the script that is spread around, infecting hundreds, if not thousands of computers. And each infected computer is deemed a slave to said botnet, also known as a zombie.

Botnets have recently been used mainly for DDoS attacks. These attacks can be used for a number of reasons - to put a ransom on the up-time of a site (threatening to kick it offline), to collect user credentials (as many bot scripts have keylogging functions), or simply to demonstrate the power one has over the internet.

A very rapid growth in IRC bots has been present and apparent recently. Bot scripts that connect to an IRC channel on the zombie computer can take direct commands once they are in the channel.

Spreading is necessary for a botnet. Spreading techniques that are most commonly used today range from drive-by downloads to torrents, 'cracked' software to Youtube videos, and everything in-between. And often times the herder will bind his bot to the true file that he is promoting for spreading, in which case the end-user is satisfied from the download, while he also is not suspicious of it.

Once the script is downloaded, however, the road to botnet domination still is not paved in gold. This is the point in which crypters and stubs come in...

Crypters are programs that use a number of techniques in order to prevent (or 'distract'Wink anti-virus software from detecting the virus that is being spread around. When a script avoids being detected by anti-virus, it is referred to as fully undetectable (FUD).

Some methods commonly used by crypters are:

- Adding junk code for modifying execution flow and various other reasons.
- Changing strings, encrypting strings.
- Changing variable names.
- Changing the order of all code aspects.
- Changing Assembly information.
- Adding or changing the icon.

This brings us to stubs. Stubs are usually .exe files, and sometimes .dll files. Basically, how undetectable the final script executable will be depends on the stub used. Some crypters have 'Unique Stub Generators' that come pre-packaged. Unique stubs allow scripts to be FUD for longer time periods.

Once anti-virus software 'learns' the stub, your script is no longer FUD, and you must use a new (unique) stub to make your script FUD once more.