Tuesday, February 27, 2007

Coding day's for fun

this code was inspired from people in forum when ask me an algorithm. this is an implementation from the algorithm. It's only for fun and for wasting a time. also to learn programming language. I hope this's not the last.

Bash script version
-------------------
start here
-------------------
#!/bin/bash
echo -n "Your input: "; read input
let temp=$input/2
let temp=$temp+1
let count=0
let i=1
echo $temp
while ((i<=input))
do
let j=1
let left=1
let right=$input
if [[ $i -le $temp ]]; then
let count=$count+1
elif [[ $i -gt $temp ]]; then
let count=$count-1
fi

while ((j<=input))
do
if [[ $left -le $count ]]; then
echo -n "$left "
elif [[ $right -le $count ]]; then
echo -n "$right "
else
echo -n "$count "
fi
let left=$left+1
let right=$right-1
let j=$j+1
done
let i=$i+1;
echo ""
done

C Version
---------------
Start here
---------------
#filename: funcode.c
int main ()
{
int input, temp=0, count=0;
int i,j,left,right;

printf ("Your input: ");scanf("%d",&input);
printf ("
Dimention: %d \n",input);
temp=(input/2) + 1;
printf("temp: %d \n",temp);

for (i=1; i<=input; i++)
{
j=1;
left=1;
right=input;

if (i <= temp)
count++;
else if (i> temp)
count--;

for (j=1; j<=input; j++)
{
if (left <= count)
printf("%d ",left);
else if (right <= count)
printf("%d ",right);
else
printf("%d ",count);
left++;
right--;
}
printf("\n");
}
return 0;
}

An output is here:
mine@unique:~$ ./funcode
Your input: 5
Dimention: 5
temp: 3
1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1
mine@unique:~$

Sunday, February 25, 2007

Linux Community Against Steven Balmer's Claim

This is from Steven Balmer's claim that linux violates Microsoft's intellectual property. Linux Community response and against this claim with make a petition that Microsoft should show the windows code that Linux has violated it.
Linux Community do it, with launch a site that contain an open letter to Steven Balmer whom make the claim again and again.
On this petition also, Linux Community calling out all Linux Developer and Open Source leader also developers for any Linux distribution or any company that feels threatened by Microsoft non-existent lawsuits.

read more...

Thursday, February 15, 2007

Setup lilo into partition's superblock and load it from grub

I already have grub installed on MBR of harddisk. It's come from my ubuntu linux. Then I installing slackware and want to use slackware's lilo to load the slackware system. First, I install lilo into superblock of slackware's partition using this command:
lilo -b /dev/hda2

note:
Slackware partition is on hda2, maybe it is different with yours, depends on your system placed in harddisk (including position of disk controller and partition). In my case, I use PATA harddisk which set as primary on controller 0. And my slackware system is on second partition.

Second, edit grub's
configuration file (menu.lst). Usually in /boot/grub/menu.lst. And then add this entry:
title Slackware Lilo
root (hd0,4) #for example, if your slackware partition in /dev/hda5
chainloader +1

Now, restart the system.

hope this helpful.