Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Apr 18, 2008

4

Update: Numbers Combination Creator

I did make a post about my script to generate numbers combination depends on user input to set the number of digits a few weeks ago. And I was thinking to make it more clean and user friendly after received a comments from "Pak Leman".

So here is the update of the scripts. The script will asked user to input the digits of combination to generate. And will asked user to give the output filename. So no more "sh script 8 > huhu.txt" . To run the script just run "sh script" and it will ask you all the details using script.

So here is the full codes of the script, and also pictures of the output:

#!/bin/sh
echo "Please give the digits for combinations[8-63]: \c"
read digit
echo "Please type the output file name: \c"
read OUTFILE

FINISH=`expr "10^"$digit"" | bc -l`

if [ $digit -lt 8 -o $digit -gt 64 ]
then
clear
echo "The digit you specify is ' $digit '. "
echo "Please enter a valid digit [8-63]: \c"
read digit
else
break
fi

COUNT="-1"
while [ $COUNT != `expr $FINISH - 1` ] ; do
COUNT=`expr $COUNT + 1`
printf "%+"$digit"s\n" $COUNT | sed s^\ ^0^g >> $OUTFILE
done

So any opinion on how to improve the script are most welcome. Somehow the script still allow digits more than 63. Still looking forward to repair this script. Any thought or advise are welcome. Please drop some comments.

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here

Apr 3, 2008

0

UBUNTU: Help promote Ubuntu

This post is about helping spreading Ubuntu Linux. I wondering when the time is just around the corner for ubuntu release, but still there is no propaganda of the Hardy Heron release hits the Malaysian Community. Here is sumthing to start with. Help promoting latest release of Ubuntu which using codename "Hardy Heron" would be appreciated.

How can you help to promote? Add a countdown widget of Hardy Heron release so that people will aware of the release date. It's not that hard to put a countdown widget on your blogs or website, just copy and paste this script and you are good to go.

This is the example of the script:


[script type="text/javascript" src="http://www.ubuntu.com/files/countdown/display.js"][/script]
But you need to make it works please change "[" to "<" and "]" to ">" as blogspot cannot make a post if there is symbol of html tags there. Hope that there will be more people willing to put countdown widget on their blogs to give awareness to Malaysian about the upcoming Ubuntu Release.

:)

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here

Mar 27, 2008

0

LINUX: Coloring your zsh shell in ubuntu

Some people will be bored looking at colorless terminal as i usually look. I do 50% of my laptop by using my terminal(CLI) on my Ubuntu 7.10 Gutsy Gibbon. I used to use bash shell a few weeks ago and bash do have some coloring on the shell, but still a lil bit boring.

But recently I change myself to zsh shell to do more shell programming. It's not the best shell for script/programming, but I get/read a lot of feedback from other linux user that this shell is suitable for shell scripting/programming.

So I this is simple tutorial on how to color your terminal to your need and make it a litle bit interesting to look at, so maybe you can spend more time to do you programming :P

First of all, you need to know the color code for shell, here is the list:

  • Choices : red, green, yellow, blue, magenta, cyan and white. The color codes for this are 30 (black), 31(red), 32 (green), 33 (yellow), 34 (blue), 35 ( magenta), 36 (cyan), 37 (white).
So now for coloring the zsh shell, you need to make a file name ".zshrc" on user's home folder. you can create the file by this command:
  • touch ~/.zshrc
After that, you need to do a litle coding to make your shell prompt. Open up your .zshrc that you just created by using any text editor of your choices. As for me, I prefer to use nano. So here is my command:
  • nano ~/.bashrc
This will open the .zshrc file inside your terminal, it is plain file without any text inside. So all you have to do is write the code. Here is some tips:
  • for prompt option you just need to add "PROMPT=" command inside .zshrc but if you would like to make some differences, you can try to do it on the right side by using this "RPROMPT="
  • here is some variable which will be recognized by shell: (%n)Username , (%B , %b)Bold text, (%~)Current Directory, (%U , %u)Underline, (%m)Machine name, (%h)Number of shell's history, (%t)Time and etc.
  • For coloring you have to use this %{\e[0;31m%} , and by changing number "31" you can change the color by the code given earlier.
  • So here is a simple example to create your prompt: paste this inside your .zshrc
    • PROMPT=$'%{\e[0;32m%}%UTell zsh what to do!%u %{\e[0m%}'
    • Save and exit.
    • Restart your terminal and you will see your prompt changing to :
      • Tell zsh what to do!
  • So you can try yourself to color up your terminal shell by writing your own .zshrc ~!
here is my screenshots:After applying the .zshrc in home folder

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here