<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Arne Aase</title>
	<atom:link href="http://www.arneaase.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.arneaase.net</link>
	<description>Stuff i find interesting</description>
	<lastBuildDate>Tue, 17 Mar 2009 22:51:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Blog update &#8211; out of winter hibernation</title>
		<link>http://www.arneaase.net/2009/03/blog-update-out-of-winter-hibernation/</link>
		<comments>http://www.arneaase.net/2009/03/blog-update-out-of-winter-hibernation/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 22:51:16 +0000</pubDate>
		<dc:creator>Arne Aase</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.arneaase.net/?p=18</guid>
		<description><![CDATA[It&#8217;s been a while since i updated this blog, so I thought i&#8217;d just write a simple list of projects I&#8217;ve been working on this winter.

Started on a personal learning environment system (php)
Made a simple webinterface for sharing content on my server (php)
Made a simple webshop in order to take a look at persistence (Java)
Ordered [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since i updated this blog, so I thought i&#8217;d just write a simple list of projects I&#8217;ve been working on this winter.</p>
<ul>
<li>Started on a personal learning environment system (php)</li>
<li>Made a simple webinterface for sharing content on my server (php)</li>
<li>Made a simple webshop in order to take a look at persistence (Java)</li>
<li>Ordered <a href="http://www.amazon.com/wishlist/22YK0U6UMNNJT ">12 new books</a> from Amazon (which i hope to read during the spring/summer)</li>
</ul>
<p>I&#8217;ve also started on my bachelor project, which we&#8217;re going to make a system using WCF services and the MVC pattern (c# and .NET).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arneaase.net/2009/03/blog-update-out-of-winter-hibernation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Book read: Drift av lokalnettverk: Design og sikkerhet</title>
		<link>http://www.arneaase.net/2008/11/book-read-drift-av-lokalnettverk-design-og-sikkerhet/</link>
		<comments>http://www.arneaase.net/2008/11/book-read-drift-av-lokalnettverk-design-og-sikkerhet/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 23:09:32 +0000</pubDate>
		<dc:creator>Arne Aase</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://www.arneaase.net/?p=14</guid>
		<description><![CDATA[Just finished &#8220;Drift av lokalnettverk: Design og sikkerhet&#8221; by Arne B Mikalsen &#38; Per Borgesen.
The book is easy read and it is good at explaining the difference between Windows, Novel and Linux but I feel it&#8217;s trying to cover too many topics and it only scrapes the surface on most of them.
Since I&#8217;m studying Information [...]]]></description>
			<content:encoded><![CDATA[<p>Just finished &#8220;<a href="http://butikk.tapirforlag.no/?q=no/node/899">Drift av lokalnettverk: Design og sikkerhet</a>&#8221; by Arne B Mikalsen &amp; Per Borgesen.</p>
<p>The book is easy read and it is good at explaining the difference between Windows, Novel and Linux but I feel it&#8217;s trying to cover too many topics and it only scrapes the surface on most of them.</p>
<p>Since I&#8217;m studying Information Technology I&#8217;ve learned about many of the topics earlier and found it unnecessary to read about these topics again especially when it didn&#8217;t give you any in-depth information.<br />
I would not recommend this book for people with Information Technology background, since most of the topics is basic stuff and it doesn&#8217;t give you in-depth information. On the other hand I&#8217;d recommend it for managers/people who are interested in setting up a local network for their organisation/business.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arneaase.net/2008/11/book-read-drift-av-lokalnettverk-design-og-sikkerhet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Guide: Simple shell script &#8211; Adding users to linux from file</title>
		<link>http://www.arneaase.net/2008/09/guide-simple-shell-script-adding-users-to-linux-from-file/</link>
		<comments>http://www.arneaase.net/2008/09/guide-simple-shell-script-adding-users-to-linux-from-file/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 18:43:03 +0000</pubDate>
		<dc:creator>Arne Aase</dc:creator>
				<category><![CDATA[Shell script]]></category>
		<category><![CDATA[is209]]></category>

		<guid isPermaLink="false">http://www.arneaase.net/?p=13</guid>
		<description><![CDATA[So we&#8217;re going to add multiple users and it&#8217;s boring to write useradd -p &#60;password&#62; -c &#60;name&#62; &#60;username&#62; on every user we want to add. why don&#8217;t we try to make a script that add users listed in a file?
Lets take a look on how it&#8217;s possible to add users from a file with a [...]]]></description>
			<content:encoded><![CDATA[<p>So we&#8217;re going to add multiple users and it&#8217;s boring to write useradd -p &lt;password&gt; -c &lt;name&gt; &lt;username&gt; on every user we want to add. why don&#8217;t we try to make a script that add users listed in a file?</p>
<p>Lets take a look on how it&#8217;s possible to add users from a file with a little shell script.</p>
<p>First we make the file with users, in the file we type username password and name separated with , and newlines</p>
<p>ex:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">Username1,pass1,full name1
Username2,pass2,full name2
username3,pass3,full name3
username4,pass4,full name4
username5,pass5,full name5</pre></div></div>

<p>Save the information in a file called users.txt, then create a new file called userscript.sh and open it in your editor.</p>
<p>Since it&#8217;s a shell script we need to tell the interpreter that it should interpret this file as a /bin/sh script, this can be done by writing:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">#!/bin/sh</pre></div></div>

<p>Then we&#8217;re all set to start writing the script, first of we need to think of what the script should do. Should it be possible to delete users from file ? In my example I will give the administrator a choice to add or delete users from file. Since we dont want to make 2 separate files with useradd script and userdel script we need to make functions and process correct function by options.</p>
<p>The first function we write is the add function:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">add()
{
	while read line
	do
		username=`echo $line | cut -d',' -f1`
		password=`echo $line | cut -d',' -f2 | mkpasswd -H md5 -s`
		name=`echo $line | cut -d',' -f3`
		sudo /usr/sbin/useradd -c '$name' -p $password $username
	done &amp;lt; $1
	exit 1
}</pre></td></tr></table></div>

<p>Okay, so what does this function actually do ? (described by line numbers)</p>
<ol>
<li>Define the function</li>
<li>Starts the function</li>
<li>Starts a loop which will loop through the file given as the first parameter line by line</li>
<li>Do the following on every line in the file</li>
<li>Create a variable named username, the variable should contain the info from line start to the first &#8220;,&#8221;</li>
<li>Create a variable named password, the variable should contain info from the first &#8220;,&#8221; to the second &#8220;,&#8221; and encrypt it to md5</li>
<li>Create a variable named name, the variable should contain info from the second &#8220;,&#8221; to the third &#8220;,&#8221;.</li>
<li>Force the /usr/sbin/useradd command to be run with root privileges</li>
<li>End while loop when every line given as the first parameter is processed</li>
<li>Exit the shell script with no errors</li>
<li>End function</li>
</ol>
<p>As you can see we use different shell commands in order to extract and process the information we want. The cut command cuts a string on a given delimiter (-d option), and -f says which cut i want (f1 first cut, f2 second cut etc).</p>
<p>Then we need to start with the delete function</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">del()
{
	while read line
	do
		username=`echo $line | cut -d',' -f1`
		sudo /usr/sbin/userdel $username
	done &amp;lt; $1
	exit 1
}</pre></div></div>

<p>I&#8217;m not going to explain this function as thorough as i did with the add function. The only difference is that we don&#8217;t need to get the password or name in order to delete, then we run the userdel command instead of the useradd command.</p>
<p>We also need to write a little help function in order to show the user how to use this little script, this is a simple functions which echo how to use the program.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">help()
{
	echo &quot;usage: -a -d -h &lt;file&gt;&quot;
	echo &quot;    -a add users listed in file&quot;
	echo &quot;    -d delete users listed in file&quot;
	echo &quot;    -h print help&quot;
	exit 1
}</pre></div></div>

<p>finally we only have to write some code to get the users options and process the right function.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">while getopts adh opt
do
	case ${opt} in
		a ) add ${!#};;
		d ) del ${!#};;
		h ) help;;
		\? ) help;;
	esac
done
&nbsp;
help</pre></div></div>

<p>This code loops through the arguments the user gave and run the appropriate function, if the user specify a option which doesn&#8217;t exist the help menu will be displayed, this also happens if the user doesn&#8217;t type a option at all.</p>
<p>You can use this script by opening a terminal and navigate to the correct folder and write &#8220;sh userscript.sh -a users.txt&#8221;, note that you have do be logged in as a user who have sudo privileges or as root in order to create the users.<br />
It would be smart to add a echo command saying which or how many users that where added/deleted.</p>
<p>Full source can be viewed/downloaded here:<br />
<a href="http://www.arneaase.net/resources/shell/users.txt">Users.txt</a><br />
<a href="http://www.arneaase.net/resources/shell/userscript.sh">Userscript.sh</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.arneaase.net/2008/09/guide-simple-shell-script-adding-users-to-linux-from-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting started with vim</title>
		<link>http://www.arneaase.net/2008/09/getting-started-with-vim/</link>
		<comments>http://www.arneaase.net/2008/09/getting-started-with-vim/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 14:27:08 +0000</pubDate>
		<dc:creator>Arne Aase</dc:creator>
				<category><![CDATA[Editor]]></category>
		<category><![CDATA[is209]]></category>

		<guid isPermaLink="false">http://www.arneaase.net/?p=12</guid>
		<description><![CDATA[Earlier this semester our teacher gave us an assignment to learn vi (vim or gvim), and make a sheet cheat in order to learn how powerful the vim editor is. When I tried to make a sheet cheat I didn&#8217;t feel that I was learning something, which is the reason I started to look for [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this semester our teacher gave us an assignment to learn vi (vim or gvim), and make a sheet cheat in order to learn how powerful the vim editor is. When I tried to make a sheet cheat I didn&#8217;t feel that I was learning something, which is the reason I started to look for other ways to learn how to use the editor. I stumbled upon a tutorial which is installed automatic if you install the full version of vim (most linux distributions come with a light version of vim so you have to install full version in order to get the tutorial).</p>
<p>To start the tutorial you just open a terminal and type &#8220;vimtutor&#8221;, the tutorial encourage the learning by doing method and is divided into small chapters which give you more and more insight on how powerful the editor is. The tutorial is opened in vim and it encourage you to do small tasks inside the tutorial while you&#8217;re reading.</p>
<p>I found this tutorial very efficient on learning the basic stuff, and would recommend every new user to go through this guide a couple of times instead of writing a sheet cheat. After you feel comfortable with the basics and how commands work it&#8217;s possible to make a sheet cheat with more advanced commands which isn&#8217;t used that often.</p>
<p>If you&#8217;re going to write code in the vim editor I would suggest to enable some features which gives you syntax highlight and smart indentation etc (type :help in normal mode to get more information on what you can do). If you&#8217;re going to write documents i would suggest to take a look at <a href="http://www.latex-project.org/intro.html">laTeX</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arneaase.net/2008/09/getting-started-with-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is Free software, Open Source and Proprietary Software ?</title>
		<link>http://www.arneaase.net/2008/08/what-is-free-software-open-source-and-proprietary-software/</link>
		<comments>http://www.arneaase.net/2008/08/what-is-free-software-open-source-and-proprietary-software/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 00:19:30 +0000</pubDate>
		<dc:creator>Arne Aase</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[is209]]></category>

		<guid isPermaLink="false">http://www.arneaase.net/?p=10</guid>
		<description><![CDATA[Free Software, Open Source and Proprietary Software is different views on which right the users should have on the software they use (modify, study, redistribute or sell the software).
Free Software Foundation is all about freedom to the people and letting the people choose to do whatever they want with the software (Modify, study, redistribute or [...]]]></description>
			<content:encoded><![CDATA[<p>Free Software, Open Source and Proprietary Software is different views on which right the users should have on the software they use (modify, study, redistribute or sell the software).</p>
<p><a href="http://www.fsf.org/">Free Software Foundation</a> is all about freedom to the people and letting the people choose to do whatever they want with the software (Modify, study, redistribute or sell), but the licence must follow the software.</p>
<p><a href="http://www.opensource.org/">Open Source Initiative</a> is for freedom to the people and are more business friendly than Free Software since they make it possible to add some restrictions, but they have a <a href="http://www.opensource.org/docs/osd">list of criteria</a> the licence must follow in order to be open source software.</p>
<p><a href="http://">proprietary software</a> is more concerned with the producer and restrict users by having copyright, patents and closed source code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arneaase.net/2008/08/what-is-free-software-open-source-and-proprietary-software/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Weekend fun</title>
		<link>http://www.arneaase.net/2008/08/weekend-fun/</link>
		<comments>http://www.arneaase.net/2008/08/weekend-fun/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 15:33:31 +0000</pubDate>
		<dc:creator>Arne Aase</dc:creator>
				<category><![CDATA[Coding competition]]></category>
		<category><![CDATA[Kodehjelp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.arneaase.net/?p=9</guid>
		<description><![CDATA[Mats hosted a little competition last weekend. The main goal of the competition was to make a program which found the shortest path from . to X in a labyrinth, and the code size should be as small as possible.
My first approach was a depth-first seach algorithm, but when I ran the code on large [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://e-mats.org/">Mats</a> hosted a little <a title="competition" href="http://e-mats.org/2008/08/finding-your-way-around-for-the-weekend/" target="_blank">competition</a> last weekend. The main goal of the competition was to make a program which found the shortest path from . to X in a labyrinth, and the code size should be as small as possible.</p>
<p>My first approach was a <a href="http://en.wikipedia.org/wiki/Depth-first_search" target="_blank">depth-first seach</a> algorithm, but when I ran the code on large labyrinths the algorithm took to long time. Then I tried a <a href="http://en.wikipedia.org/wiki/Breadth-first_search">breadth-first search</a> algorithm which proved much faster and stable on finding the shortest path.</p>
<p>Even if I did manage to get my code down to 518 bytes, I didn&#8217;t even get close to the winner, which got it down to 253 (results can be found <a title="here" href="http://e-mats.org/2008/08/the-results-of-our-weekend-challenge/" target="_blank">here</a>). You can take a look at my code <a href="http://www.arneaase.net/resources/kodehjelp/maze_pretty.phps" target="_self">here</a>, it isn&#8217;t as advanced as the other examples shown on mats&#8217; page but it works and finds the correct answer quickly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arneaase.net/2008/08/weekend-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing And Using A Fileinfo Resource In php</title>
		<link>http://www.arneaase.net/2008/08/installing-and-using-a-fileinfo-resource-in-php/</link>
		<comments>http://www.arneaase.net/2008/08/installing-and-using-a-fileinfo-resource-in-php/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 19:59:34 +0000</pubDate>
		<dc:creator>Arne Aase</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.arneaase.net/?p=8</guid>
		<description><![CDATA[My server is finally up and I started writing a little web script to unpack and move files from a local place on disk to a ftp folder. I decided to use php since it is a language i know and it is quite efficient on small programs.
I bumped into some problems installing the fileinfo [...]]]></description>
			<content:encoded><![CDATA[<p>My server is finally up and I started writing a little web script to unpack and move files from a local place on disk to a ftp folder. I decided to use php since it is a language i know and it is quite efficient on small programs.</p>
<p>I bumped into some problems installing the fileinfo resource extension when using a windows server. I used the php msi installer to install php and used the same installer to add the fileinfo extension, but the installer didn&#8217;t include all the files. You also need some extra files in the php/extras folder, these files can be found on <a title="sourceforge" href="http://sourceforge.net/project/showfiles.php?group_id=23617&amp;package_id=18878" target="_blank">sorcefourge</a>. You need the magic and magic.mgc files located in the bin package.</p>
<p>When the extension was successfully installed I tried with a simple example to see if it would match the filetype.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">$fi = new finfo(FILEINFO_MIME, 'C:\PHP\extras\magic');
echo 'filetype ' . $fi-&gt;file('e:\test.rar');</pre></div></div>

<p>this code should print &#8220;filetype application/x-rar&#8221;, but it showed application/x-dpkg instead. The reason was that windows returns a match if the condition starts with &#8220;!&#8221;, so i had to add &#8220;\&#8221; in front of every condition that started with &#8220;!&#8221; in order to get a correct match.</p>
<p>example:</p>
<blockquote><p>0    string        !&lt;arch&gt;\ndebian application/x-dpkg<br />
should be:<br />
0    string        \!&lt;arch&gt;\ndebian application/x-dpkg</p></blockquote>
<p>If you don&#8217;t like to use objects you could use this code instead:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">$fi = finfo_open(FILEINFO_MIME, 'C:\PHP\extras\magic');
echo 'filetype: ' . finfo_file($fi, 'e:\test.rar');</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.arneaase.net/2008/08/installing-and-using-a-fileinfo-resource-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Model-View-Controller Pattern</title>
		<link>http://www.arneaase.net/2008/07/model-view-controller-pattern/</link>
		<comments>http://www.arneaase.net/2008/07/model-view-controller-pattern/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 00:55:55 +0000</pubDate>
		<dc:creator>Arne Aase</dc:creator>
				<category><![CDATA[Code design]]></category>

		<guid isPermaLink="false">http://www.arneaase.net/?p=7</guid>
		<description><![CDATA[Earlier this summer I started a project where the goal was to learn more about code design. I asked different people on which code design they preferred and ended up with the mvc-pattern. My first thoughts when I read about it where that the idea was good but I couldn&#8217;t visualize how the code would [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this summer I started a project where the goal was to learn more about code design. I asked different people on which code design they preferred and ended up with the <a title="model-view-controller" href="http://en.wikipedia.org/wiki/Model-view-controller">mvc-pattern</a>. My first thoughts when I read about it where that the idea was good but I couldn&#8217;t visualize how the code would be, so I decided to make a simple website using the pattern. After the website was done, I tried adding more functionality to the site, which was really easy and it made me wonder why we don&#8217;t learn stuff like this at school when we start programming. Wouldn&#8217;t it be better if people learned about different patterns and code design when they started learning about programming instead of first have to learn about programming, then have to restructure their coding styles to be more efficient/scalable ?</p>
<p>If you look at the advantages by a good code design the answer should be yes, but there are pros and cons to this. If the instructor choose to implement the code design in the course it means that he have to remove other topics. What topics could the instructor remove? The students have much new information to process and remember, would the code design part make them more confused or would it help them to get a better overall picture about programming?</p>
<p>I personally think the code design part would make the average student more confused, which again makes more students drop out. But I also think that code design is important to programming, and every programmer should think about their code design.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arneaase.net/2008/07/model-view-controller-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World</title>
		<link>http://www.arneaase.net/2008/07/hello-world/</link>
		<comments>http://www.arneaase.net/2008/07/hello-world/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 19:10:02 +0000</pubDate>
		<dc:creator>Arne Aase</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.arneaase.net/?p=4</guid>
		<description><![CDATA[I&#8217;ve finally found my way to the blogging part of the Internet, which is the reason I&#8217;m starting my own blog. This blog wont have any specific content, since I&#8217;m going to use it to write down thoughts and notes on stuff i find interesting.
Time will tell how much and which content this site will [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally found my way to the blogging part of the Internet, which is the reason I&#8217;m starting my own blog. This blog wont have any specific content, since I&#8217;m going to use it to write down thoughts and notes on stuff i find interesting.</p>
<p>Time will tell how much and which content this site will be filled with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arneaase.net/2008/07/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
