Nothing To Lose

If you don’t have it, how can you lose it!
Subscribe

Archive for April, 2009

Setting date on Linux through the command line

April 27, 2009 By: Dexter Category: BASH, Linux, Linux Commands

It has always been said the setting the date through the command line is tough.  Well I found it very very simple.

By default date command displays the current system date and time.

To set the system date and time you can use the - -set option  with the date string.  Of course to do that you will need root access.

( - - set ( hyphen hyphen set) without spaces. some browsers combine the two hyphens)

ie.  date  - -set=’dd/mm/yyyy hh:mm:ss’

or

date  - -set=’27/04/2009 20:10:05′

that should set your date :)

[end]

Catching email id’s from file(s) using grep and other utils

April 18, 2009 By: Dexter Category: BASH, Linux Commands, Regular Expressions, Shell Scripting, Tutorial

Here is a simple mechanism that you can use to collect all the email id(s) from a file(s) into a single file. To do this we will be using the following command cat , grep, sort and uniq.

This one liner should do the work

cat file | grep -io ‘\<[^-.][0-9A-Za-z\.\-\_]\+@[0-9A-Za-z.]\+\>‘ | sort | uniq

If you want all the id’s in some file then redirect the above command to a file.

cat file | grep -io ‘\<[^-.][0-9A-Za-z\.\-\_]\+@[0-9A-Za-z.]\+\>‘ | sort | uniq > mailid.txt

Now lets convert this into a shell script where we shall accept a directory name from the user. This directory will be the one containing the files having the email ids
You can download the script from here Script to retrieve Email ids form files in a directory
I have noticed the copy paste of the code below is not working because of formatting characters.

#!/bin/bash
clear
echo -n “Enter the name of a DIRECTORY from where you want to pick up email id’s: “;
read dirname;

# check if the entered name is a directory

if [ -d $dirname ];then

cd $dirname; #  if it exists change to the directory

else

echo “+============================+”

echo “| Check your directory name! |”

echo “+============================+”

exit 1;

fi

# Loop through all file  in the given directory

for files in *

do

if [ ! -d $files ];then

# process all files and store them in a temporary file in users home dir

echo “Processing file $files”;

cat $files | egrep -io ‘\<[^-.][0-9A-Za-z\.\-\_]+@[0-9A-Za-z.]+\>‘ >> ~/$$;

echo “Processed”;

fi

done

cd -  # get back to previous working dir, i am assuming it was home

# sort the emails ids in the file, remove duplicates and store in a final file.

sort ~/$$ | uniq >> emailids.$$

# remove the temporary file

rm ~/$$

# tell the user where the mail ids are stored

echo

echo “+=================================================+”

echo ” Your email ids are available in ~/emailids.$$ ”

echo “+=================================================+”

exit 0;

Well I should warn you, the regular expression will catch anything that looks like an email id, so you might end up having lots of things that looks like an email id.
[end]

Jigsaw Sphere With Text

April 13, 2009 By: Dexter Category: GIMP, Tutorial, Web Graphics

Here is a very simple way to have a sphere made out of jigsaw pieces with text on it using GIMP

1) Start with a square canvas, I have taken 256×256 pixels size. Go to filters — Render — Jigsaw. select the curved style from jigsaw options and increase number of vertical and horizontal pieces to 9, or whatever you like. You should get something similar to IMAGE 1

Jigsaw Pattern

IMAGE 1 Jigsaw Pattern

2) Add required text in few of the pieces, Since you have to place text in different pieces you will have to put each character one at a time. You should have something similar to IMAGE 2

IMAGE 2 - Jigsaw with text in it

IMAGE 2 - Jigsaw with text in it

3) Finally on this image run filters — Map — Map Objects - Select Sphere as the object to be mapped to. Play around with the orientation tab to move the sphere in x y or z axis etc. Once you are satisfied with the settings click ok. You should get you sphere ready. See IMAGE 3

IMAGE 3 - mapped to sphere

IMAGE 3 - mapped to sphere

Little Shiny Blue Button

April 09, 2009 By: Dexter Category: GIMP, Tutorial, Web Graphics

For last few day had been doing some designing. Had to make some buttons, so here is a tutorial for making a rounded cornered shiny button. And of course using GIMP Blue Button
  • Start with a canvas of comfortable size, say around 400×600. Even though our button is going to be small, its some times easier to work on a bigger canvas and then to crop to the actual size.
  • Now we will make a square selection, from the tool box, select rectangular selection tool. Set the following in its setting, Anti-aliasing, Rounded Corners: Radius 20 and Fixed size: 150×150px.
  • Now do a selection in center of the canvas, you should get a selection of 150×150px automatically with rounded corners. ( See Image 1 )
IMAGE 01

IMAGE 01

  • Select some dark blue (I used #0000E2) as you foreground color, the select the gradient fill tool. In the settings choose, Mode: Multiply, Gradient: foreground to background RGB. Offset: 20, Shape: linear, Check Dithering and Adaptive supersampling.
  • Now using the gradient fill tool click at the bottom of the selected square selection and drag till the upper part of the selection. You should see an image similar to IMAGE 2
  • Run the previous step again but this time start from a bit out side the upper part of the square selection and drag just almost till the blue start to appear and leave the mouse button. You should get some thing similar to IMAGE 3.
  • Now just cut and paste the selected area againl (^c and ^v). Press ^L to invoke the layer dialouge box, you will see a floating layer, click on the lower left icon/button (create new layer) of the dialog box, this will make the floating layer as a new seperate layer. Name this layer as (button-gradient)
  • Next select the button-gradient layer to work on from layer dialog box, press ^a and ^c, this will select that layer and paste a copy of the layer again.
  • Now select a even darker blue (#000080) as foreground color, go to edit menu and click on “Fill with foreground color”. Your image should be filled with the new blue color, Go to the layer dialog box and paste this as a new layer. Lets call it as the dark-border layer.
  • Next select your latest layer to work on, use “fuzzy select tool” to select all, it should select the outside of the box. Next from “select” menu choose, “shrink”. Use shrink value of 5px. You should get an image similar to IMAGE 4.
  • Hit the delete key, and you will be able to see the gradient layer!!!!.
    IMAGE 5
  • Now the button is ready. But it looks a bit flat. So lets add some shadow to the button. Select the dark-border layer to work upon. Go to filters, select “light and shadow” => “Drop Shadow”, set parameter to x and y offset to 0 (zero), and hit ok.
  • And your button is ready. Enjoy.
    IMAGE 6
  • For actual usage, its better to delete the background (White) layer, and then re-size the image to the Shadow layer.

IMAGE 2

IMAGE 2

IMAGE 3

IMAGE 3

IMAGE 4

IMAGE 4

IMAGE 5

IMAGE 5

IMAGE 6

IMAGE 6

There is a easy way to create more buttons of similar type in different colors, merging the layers of the image and then using the “Hue-Saturation” from “color” menu. Play around with it and enjoy.

Here are some sample buttons in different colors and gradients.

Blue Button

Blue Button

Red Button

Red Button

Green Button

Green Button

Brown Button

Brown Button

[end]