reply

There is an example in the Bash Cookbook (p. 140, O’REILLY 2007: Albing, Vossen and Newham) that shows you how to make an rpn calculator. I’ve extended it to support desimals provided you have bc. Enjoy:

#!/bin/bash

BC=`which bc`
scale=${SCALE:-2}

if [ $# -lt 3 -o $(( $# %2 )) -eq 0 ]
then
        echo "Usage: $0 int int operator [int operator ...]"
        echo "       x same as * (multiply)"
        echo "       set \$SCALE to a desired precision (other than two)"
        exit 1
fi

if [ -x $BC ]
then
        ANS=`echo "scale=$scale;${1}${3//x/*}$2"| bc`

else
        echo install bc to use decimal expressions: http://www.gnu.org/software/bc/bc.html
        ANS=$(($1 ${3//x/*} $2))
fi

shift 3

while [ $# -gt 0 ]
do
        if [ -x $BC ]
        then
        ANS=`echo "scale=$scale;${ANS}${2//x/*}$1" |bc`
        else
        ANS=$(( ANS ${2//x/*} $1 ))
        fi
        shift 2
done
if  [[ ${ANS} =~ ^\. ]]
then
        #echo leading dot
        echo -n 0
        echo ${ANS}
else
        echo ${ANS}
fi

I might add input sanitation in the future: /whatever/shellscripts/rpncalc.sh

[WRITTEN] 16. Feb 2010 18:02 [CATEGORY] Uncategorized

reply

Your computer is generally slow. To fix the problem, you need to hire me for a
couple of hours and I will build a super-nice system for you at a reasonable fee.
Unit then, there is a temporary solution. It is called disc defragmentation.
The basic idea behind the process is to move all files (and parts of files) to
one location on the hard drive. So instead of being scattered all over, they are
neatly condensed in one area. This makes everything faster because Widows will
spend less time waiting for the hard drive and concentrate more on what you
tell it to do.

just read the instructions here:

http://genja.org/instructions/clean-defrag/

[WRITTEN] 22. Jan 2010 00:01 [CATEGORY] instructions, windows

reply

reporter: you’ve written that in looking at contributions of gifted thinkers, one must make sure to understand their contributions, but also to eliminate the errors in them? um.. and of your ideas.. what would you guess would be discarded? and what would be assimilated by future thinkers?

chomsky: well.. um, I mean, I assume virtually everything would be discarded. ahm.. for example in eh, he- here we have to distinguish. I mean the work that I do in my professioanal area. I mean if I still believed what I believed ten years ago, I’d assume the field is dead. uh, so I assume that when next time you read a student’s paper, you’re gonna see someting that got to be changed – and you continue to make progress. In dealing with social and political issues – I – in my view what is at all understood is pretty staight forward. I don’t think that… they may be deep and complicated things …but if so, they are not understood, uh, the uh, the, the basic way – to the extent that we understand society at all – it’s pretty staight forward. and I don’t think that those simple understandings are likely to undergo much change.

[WRITTEN] 28. Dec 2009 06:12 [CATEGORY] citations

reply

It is a poor service to the memory of the victims of the holocaust to adopt a central doctrine of their murders.

– Noam Chomsky

[WRITTEN] 28. Dec 2009 05:12 [CATEGORY] citations, philosophy

reply

I’ve been reading Terrence Mckenna recently and there is a passage in his Archaic Revival that you need to read and understand:


If things can be seen differently, how many ways can they be seen differently? Try to get people to stop waiting for the president to enlighten them. Stop waiting for histrory and the stream of historical events to make itself clear to you. You have to take seriously the notion that understanding the universe is your responsibility, because the only understanding of the universe that will be useful to you is your own understandding. It doesn’t do you any good to know that somewhere in some computer there are equations that perfectly model or don’t model something that is going on. We have all tended to give ourselves away to official ideologies and to say, “Well I may not understand, but someone understands.” The fact of the matter is that only your own understanding is any good to you. Because it’s you that you’re going to live with and it’s you that you’re going to die with. As the song says, the last dance you dance, you dance alone.

p. 88 Archaic Revival 1991
—-

I always love reading my own thoughts articulated by other people. Note that the emphasis here, is not that everyone is alianeted, but that they need to form independent opinions and gain knowledge based on their own experiences.

[WRITTEN] 26. Dec 2009 09:12 [CATEGORY] citations, philosophy

reply

Earlier this year I enrolled into the university to become a computer scientist. Not sure that is a real title, but you get the point. The first semester is now behind me. One of the subjects I had this semester is called Introduction to Informatics (IT1101). I gotta say it was boring, partly becasue I already knew 70% of the cirricilum and partly because the professor was useless. This was anticipated, though, and the professor has aducated many before me, and will continue to teach others after me I guess. Never the less, patience is one of my graces and I did go to the first 5-7 lectures. It turned out that the 30% of the course that I did not know were useless detailes. This made me thoroughly sure that I did not need to visit these classes. In the end I spent three days reading the book and preparing for the exam with a fellow student. I did read the first six chapters (Computer Science. Brookshear) before the course started as well. I’m pretty sure it went fine.

Besides from that I had Basic Programing (IT1103). Boring too, but I got the opportunity to familiarize myself with Java, which is nice. The exam did not go to well because I spent the first 90 minutes (37 percent of the examination time) trying to wake up. It is alright though, because I am sure that no one else in that room was out getting pissed the night before. I regard this a self-inflicted handicap intended to prove to myself that IT is my domain and I need only to be half awake to pass the exams. I think it worked out, I will get B or C on the programing and B or A on the cs-intro course. I think getting drunk before these two exams was a necessity. Now I can brag about it – one – and two – I know that it is a bad idea. Know as in have experienced it, meaning there is no way I am going to do it later in my studies. It is actually pretty funny, because I nearly missed the second exam. I got up five minutes before it began, and came in ten minutes late. They let me do the exam, however. real lucky.

The third subject was Basic Calculus (MA1101). I found the course to be interesting, but the width of the material required more effort than I could give. I rationalize that it has been two and a half years since I have had any math, and that I finished only half the course of the last years math in high school (on which this course is based). In reality though, I am begining to think that my thinker is not as well suited for math as previously believed. Perhaps my logic is clouded due to the all of the lamb’s bread. I am not even certain that I will pass the exam, and that fact is bothering me. I wil be doing basic calculus II (ma1102) this semester and it remains to see if the gap that was between my knowledge and the requirements of the first course has been reduced enough for me to get a good grade in the second course. I am with a strong heart about this and with a lucid head combined with some effort, I could nail a B. Time will show.

The last course was about philosophical schools and the “scientific revolution” with the Newton dude & co (EXPH0001). Interesting stuff, but somewhat difficult to take seriously (because I like to think that my own views on humanity, moral and the concept of being are better, even though not even close to being as well articulated, or even put down on paper). The main objective of this course is to make the students understand how to write scientific articles and how to argue for different views on a problem. I think many students underestimate the value of that. But then again, they are probably better than me at writing that sort of thing. I hate discussing in a paper, I simply go “this is how it is – accept it and you know that i’m right”, but that seems to be the wrong way to reach the reader. Anyway, I read next to nothing from the book and ditched the lectures from early on. That said, the exam could not have gone better than it did. There were three questions, of which we were supposed to pick one. I was really lucky because I had actually read about Hume, Kant and Descartes. Long story short, I turned in eight pages and I expect a C.

[WRITTEN] 25. Dec 2009 16:12 [CATEGORY] log

reply

“I’ve Seen It All”

I’ve seen it all, I have seen the trees,
I’ve seen the willow leaves dancing in the breeze
I’ve seen a man killed by his best friend,
And lives that were over before they were spent.
I’ve seen what I was – I know what I’ll be
I’ve seen it all – there is no more to see!

You haven’t seen elephants, kings or Peru!
I’m happy to say I had better to do
What about China? Have you seen the Great Wall?
All walls are great, if the roof doesn’t fall!

And the man you will marry?
The home you will share?
To be honest, I really don’t care…

You’ve never been to Niagara Falls?
I have seen water, its water, that’s all…
The Eiffel Tower, the Empire State?
My pulse was as high on my very first date!
Your grandson’s hand as he plays with your hair?
To be honest, I really don’t care…

I’ve seen it all, I’ve seen the dark
I’ve seen the brightness in one little spark.
I’ve seen what I chose and I’ve seen what I need,
And that is enough, to want more would be greed.
I’ve seen what I was and I know what I’ll be
I’ve seen it all – there is no more to see!

You’ve seen it all and all you have seen
You can always review on your own little screen
The light and the dark, the big and the small
Just keep in mind – you need no more at all
You’ve seen what you were and know what you’ll be
You’ve seen it all – there is no more to see!
——–

This song captures the desired state of mind of the individual who would feel like the song describes her state of mind. An existence where all is fair and equal is desirable because it is constant and reliable.
There is nothing in this song to contradict the above resolution except the last stanza. In it, the voice transforms from being strictly wishful and descriptive about interior reflections, to doubt. – you’ve seen it all and all you have seen – is nothing but your own conceptions, remember that the outside is formed by your interior feelings. The song simply begs the sceptic, the determined mind, to reconsider.

I find this a truly powerful suggestion.

[WRITTEN] 21. Nov 2009 03:11 [CATEGORY] Uncategorized

reply

Я познакомился с Евгением, героем Пушкина недавно.
Его рассказ читать забавно, но про себя читать печально.
В чертах характера героя я узнаю на мир свои взгляд
разочарованный, ледяной.
Да и пристрастия доля мне как Онегину попалась.

:’(

[WRITTEN] 09. Nov 2009 06:11 [CATEGORY] Uncategorized

reply

ever get tired of passwords? one of the areas where you can avoid re-entering password is with ssh logins. if you have a couple of boxes or even shells, then this will come in handy.

make a pair of keys.


$ mkdir ~/.ssh; ssh-keygen -d

copy your public key (~/.ssh/id_dsa.pub) to your authorized keys file (~/.ssh/authorized_keys) on a remote host

$ ssh-copy-id -i ~/.ssh/id_dsa jaroslav@tryggve.lan
($ cat ~/.ssh/id_dsa.pub |ssh jaroslav@tryggve.lan cat - \>\> \$HOME/.ssh/authorized_keys)

now shell into that remote host

ssh jaroslav@tryggve.lan

voila!

if you didn’t set a pass-phrase in the first step, you can do so now by issuing the command
ssh-keygen -p

the beauty of not having a password should be self-evident, the risk too. to avoid the risk and keep the benefits of ssh keys there is ssh-agent.

eval `ssh-agent`
ssh-add

…will span a key-agent in the background and add the identity of the private key you created in step one to that agent. now you can do just as you would without a password. for example:

remotely:
ssh jaroslav@tryggve uname -norp
host: tryggve.lan
tryggve 2.6.26-cpufreq AMD Athlon(tm) 64 Processor 3200+ GNU/Linux

locally:
$ uname -norp
raptor 2.6.29-cpufreq-video Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz GNU/Linux

this is swell and fine, but opening new terminals or even killing your x would cause you to lose the socket name of the agent unless you do something like

ssh-agent > .variables
source .variables

that would work even from a different terminal. this is actually how i did it for a while:
alias ssh-agent="ssh-agent > .agent-ssh; source ~/.agent-ssh"

but that solution if flawed because old sessions of the agent are piling up and could pose a risk as well as … whatever.. it’s just not right.
thus i came up with

#
# the script is intended to be sourced from .bashrc
#
# it will start a new ssh-agent when you log in or connect you to the one
# already running. mind you if there are other ssh-agent(s) running for the
# current user with variables stored elsewhere than .ssh/vars.sh this script
# will do nothing to regain or remove them.
#
# original script found at http://www.nyetwork.org/wiki/SSH
# and as the author there says, it will not produce any output thus letting
# things like scp or rsync run smoothly
# latest version can be found here: http://genja.org/whatever/shellscripts/agent-ssh
#
# –jaroslav, genja.org
#
#
#
#
# rxvt rxvt-unicode woot

#
# leave unset if you wish to run ssh-add manually

ASK4PASS=yes

#Time format examples:
#
# 600 600 seconds (10 minutes)
# 10m 10 minutes
# 1h30m 1 hour 30 minutes (90 minutes)

SSH_AGENT_LIFE=”-t 90m”

SSH_VARS=$HOME/.ssh/vars.sh

# everything below this line should work without intervention
#

#
# this ps line works with:
# Linux procps version 3.2.7 http://procps.sourceforge.net/
# other *nixes will need different ps arguments
# TODO make a case `uname` in Linux)PSARGS=lol;; *BSD)PSARGS=blol;; Darwin)PSARGS=dlol;; esac
case `uname` in
Linux) psA=’-a -o pid,args -p’;;
AIX) psA=’-a -o pid,args -p’;;
SunOS) psA=’dunno…’;;
*BSD) psA=’axwwo pid,args’;;
Darwin) psA=’dunno..’;;
CYGWIN_NT-5.1) psA=’-e -f -a -p’;;
esac

# source the variables file and find out wether ssh-agent is
# still running
#
[ -s $SSH_VARS ] && . $SSH_VARS >/dev/null && \
RUNNING=`ps $psA $SSH_AGENT_PID |grep [s]sh-agent`

#
# do we have an agent?
#
#
if [ "$SSH_AUTH_SOCK" == "" ] || [ ! -e "$SSH_AUTH_SOCK" ]\
|| [ ! -S "$SSH_AUTH_SOCK" ] || [ "$RUNNING" == "" ];
then

VAR=`ssh-agent 2>/dev/null`
eval $VAR >/dev/null

echo $VAR > $SSH_VARS
fi

# ask for pass-phrase on interactive shells
NOID=”The agent has no identities.”
if [ $ASK4PASS ]; then
case “$-” in
*i*) [ "$NOID" = "`ssh-add -l `" ] && ssh-add $SSH_AGENT_LIFE ;;
*) ## stay quiet ;;
esac
fi

for more information you could check out the following manuals:

$ apropos ^ssh[^d]
ssh (1) – OpenSSH SSH client (remote login program)
ssh-add (1) – adds RSA or DSA identities to the authentication agent
ssh-agent (1) – authentication agent
ssh-copy-id (1) – install your public key in a remote machine’s authorized_keys
ssh-keygen (1) – authentication key generation, management and conversion
ssh-keyscan (1) – gather ssh public keys
ssh-keysign (8) – ssh helper program for host-based authentication
ssh_config (5) – OpenSSH SSH client configuration files

[WRITTEN] 09. Oct 2009 14:10 [CATEGORY] Uncategorized, geek

reply

The Norwegian online press has grabbed gradually less of my attention. The articles show no literary prowess, and the news are simply translated from other online sources. Unless, of course, they are talking about cattle and domestic politics. The more I visit web-papers (vg.no, db.no adressa.no, itavisen.no to name a few), the less I want to come back. Here is an interesting header for you:

Av Harald Brombach, tirsdag 22. september 2009 kl 07:43

Nå skal Telenor og DnB NOR teste mobilbasert betalingsløsning.
Mange har snakket lenge om å bruke mobiltelefonen til å betale småutgifter, for eksempel når brukeren handler fra en automat hvor man i dag må putte på småpenger. Årsaken til dette er at kontanter både er upraktisk for brukeren og kostbart for både banknæringen og samfunnet forøvrig.

closely translated this means:
Telenor and DnB NOR are about to experiment with payments over the cellular grid.
Many have talked for a long time about using their mobile phones for casual transactions similar to coin machines in grocery shops and vending machines in general. The reason is because cash is both inconvenient for the consumer and costly for both the banking industry and society at large.

full article: Sim kort vil erstatte bankkort

I think only a Norwegian news article writer can fit the word both two times in a sentence. That is not the point, however.
Mister Brombach writes that cash is inconvenient. Clearly he is a bit less paranoid than a certain swede I have lived with. That guy makes a point by dragging his Swedish passport to the bank every week or so to draw some cash. He is absolutely positive that plastic cards are monitored and refuses to use them. I am fairly certain that anyone when asked will agree with Harald. It is really a drag counting and carrying the heavy kroner coins of 0.5, 1, 5, 10 and 20, in addition to the bills of 50, 100, 200, 500 and oh! The really big one of 1000. I mean, did any one ever think we would use math in real life once we left school?
I might be very arrogant and selfish in saying this, but this particular inconvenience of mine is more valuable than the expenses of the banking industry and the society combined. The charges for production and distribution of money go out from my pocket, as ruled by the government of the society, and end up at the bank anyhow, probably. I say let them pay for their fiat currency. Besides, the Swede has a point.

[WRITTEN] 23. Sep 2009 02:09 [CATEGORY] economy, internet, ¤%"#!$
keep looking »