Sunday, January 24, 2010

Mortgage calculator - bash script

This simply outputs the monthly mortgage payment.

Takes five arguments : principle years interest points fees

For instance,

bash mortgage.sh 100000 5 .075 0 0

Outputs

Principle + fees = 100000 , Years = 5 , Months = 60 , interest .006250000000
Points = 0 , 0
2003.794859563881




#!/bin/sh

if [[ $# -ne 5 ]]
then
echo "enter 5 args : principle years interest points fees"
exit
fi

prin=$1
((mon=$2 * 12 ))
inter=`echo "scale=12;$3/12" | bc`
pts=`echo "scale=12; $prin * $4" | bc`
fee=$5
prin=`echo "scale=12;$prin + $fee" | bc`


echo "Principle + fees = $prin , Years = $2 , Months = $mon , interest $inter"
echo "Points = $4 , $pts"

prin=`echo "scale=12; $prin - $pts" | bc`


echo `echo "scale=12;($prin*$inter)*((1+$inter)^$mon)/(((1+$inter)^$mon)-1)"|bc`
echo "the monthly payment : $new_prin"



Sunday, January 17, 2010

start menu pin list location



> If I pin a shortcut to the startmenu, where does XP store this
> information?

With a shortcut in this folder...
C:\Documents and Settings\All Users\Start Menu

The above folder would be the easiest.

Also here...
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\MenuOrder\Start Menu2\Programs
Value Name: Order

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\StartPage
Value Name: Favorites
Value Name: FavoritesResolve

All of those are REG_BINARY values and hard to read them.

Monday, January 11, 2010

Bash - Gaussian Elimination Op count example



#!/bin/sh

if [[ $# -ne 2 ]]
then
exit
fi

echo " m $1 by n $2 matrix"

n=$2
m=$1
mult=0
add=0
c=0

for ((i=1;i < m;i++))
do
echo "row = i = $i"
for ((j=i;j < m;j++))
do
((mult=mult + (n-i+1)))
((add=add + (n-i+1)))
done
((c=c+(m-i)*(n-i+1)))
done
echo "additions = $add"
echo "mults = $mult"
echo "summation = $c"



Matlab - simple newton's method ex



function r = doNewton(f,x0,x,err)

while abs(x0 - x) > err

x0, (x0 - x)

x0 = x0 - (polyval(f,x0))/polyval(polyder(f),x0);


end



r = x0;
end