Jun
01

Pythons Simple HTTP Server

There is a nice little feature in Python that a friend of mine showed me. You may use Python as a Web Server… and that is right out of the box. No additional programs to install or any tweaking at all 🙂

Move to the folder you want to make available for others to see.
Then type
python -m SimpleHTTPServer

If you want to use a special port you may type something like this:

python -m SimpleHTTPServer 8713

Others may browse your directory and directories below.
If you haven’t specified a port, in your browser type :
http://your.ip:8000/

Or, if you have specified a port
http://your.ip:8713/

Enjoy 🙂

Mar
08

Protected: Markus støvsuger

This content is password protected. To view it please enter your password below:

Feb
26

Markus tar 3 skritt

Markus tar tre prøvende skritt i dag …

Feb
25

Calculate standard deviation using AWK

The standard deviation ? (sigma) is the square root of the average value of (X – ?)2.

In the case where X takes random values from a finite data set x1, x2, …, xN, with each value having the same probability, the standard deviation is

  where mu

Assume we have an input file foo with f.ex. line number in first column and in the second column ($2 in awk) we have the values of interest.

File: foo

1 2
2 3
3 6
4 8
5 11

Use the one of the following awk commandos to calculate the standard deviation

awk ‘{sum+=$2; array[NR]=$2} END {for(x=1;x<=NR;x++){sumsq+=((array[x]-(sum/NR))^2);}print sqrt(sumsq/NR)}’ foo

awk ‘{sum+=$2;sumsq+=$2*$2} END {print sqrt(sumsq/NR – (sum/NR)^2)}’ foo

The result is

3.28634

Average

Here you may find how to calculate the average or arithmetic mean using AWK.

Minimum and maximum

Here you may find how to calculate the minimum and maximum values using AWK.

Feb
22

Protected: Markus og elgen går

This content is password protected. To view it please enter your password below:

Jan
12

Takk … takk

Markus sier “takk” og “takk, takk”.

Oct
27

Hard Drive Crashes … foremost to the rescue

If your hard drive crashes … you may use foremost to retrieve your documents, photographs and so on.

Foremost is a linux tool for conducting forensic examinations. Although intended for law enforcement purposes, it may be useful to other members of the community. Foremost reads through a file, such as a dd image file or a disk partition and extracts files.

Foremost is available for most *nix platforms and Windoze via CygWin. Foremost is useful when you can’t mount a ddrescue image.

Execute the following command:

foremost -t all -i my_crashed_harddrive.dd

… and all your documents should hopefully be rescued 🙂

Oct
16

Plum Jam Recipe

Here is an easy recipe for Plum Jam…

Prep Time: a few min
Cook Time: 15 min

Ingredients:

  • 1 kg plums, split in four, seeds discarded
  • 1/2 dl water
  • 3-4 dl sugar
  • juice of 1 lemon

Preparation:

Rinse and split plums in four and discard the seeds.
Place plums, water, and lemon juice in a non-aluminum stockpot. Bring to a boil and reduce heat to low, and let simmer for 15 minutes, stirring occasionally, until fruit is soft.
Stir in sugar and bring back to a rolling boil while constantly stirring.
Enjoy!

Sep
16

Flight from Tromsø to Oslo

A few weeks ago (26. Aug) I visited Tromsø during my work. We have a Bell sea gravimeter (BGM-3) which was located at M/S Franklin. The instrument had been located on this ship for a few months and it was time to unmount it.

After a few hours of work the instrument was safely stored at our land based storage, and I was able to pay a short visit to my cousin here in Tromsø.

On my return flight to Oslo the weather was quite nice and and I manged to take a few picture of Senja, Lofoten, a glacier (Svartisen) and sunset in the Oslo area.

The first picture shows Senja, with the island Andøya in the background. On Senja you may see the fjords; Gryllefjord, and Sifjorden, and you may also spot the places Grunnfarnes and Kaldfarnes among other.

Sifjord, Veimann, Kaldfarnes, Gryllefjord

Here we see the bridge over to Sommarøy and Hillesøy (Senja)

Sommarøy

The glacier Svartisen not far from the city Bodø

Svartisen

Sunset seen from the plane.

Sunset from the airplane

Aug
11

SSH and RSYNC without password

Tried of typing your password every time you use ssh or rsync? If so, you should create a local ssh key for your computer and append your key to the remote computers you usually login to.

1. Generate your ssh key on your local computer:

local> ssh-keygen -t rsa

2. If prompted for file name to store your key, select the default (id_rsa).

3. Do not enter a password when asked. This will generate a password-less key and a public key. If you have   selected the default names, then those will be: id_rsa (password-less key) and id_rsa.pub (public key)

4. Copy the public key (id_rsa.pub) to the machine you want to ssh/rsync to. Avoid overwriting your RSA key at your remote host by renaming it first.

local> cp id_rsa.pub yourlocal_key.pub

local> scp yourlocal_key.pub you@remote-machine:

remote> cat yourlocal_key.pub >> .ssh/authorized_keys

remote> rm yourlocal_key.pub (cleaning up)

And now your remote computer will accept a ssh login without prompting you for a password.

Older posts «

» Newer posts