<?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>Philipps Blog</title>
	<atom:link href="http://www.philipp.haussleiter.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.philipp.haussleiter.de</link>
	<description>my personal Site of Things</description>
	<lastBuildDate>Fri, 11 May 2012 23:50:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Hacking just for Fun: using Bookmarklets</title>
		<link>http://www.philipp.haussleiter.de/2012/05/hacking-just-for-fun-using-bookmarklets/</link>
		<comments>http://www.philipp.haussleiter.de/2012/05/hacking-just-for-fun-using-bookmarklets/#comments</comments>
		<pubDate>Fri, 11 May 2012 23:18:55 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Play! Framework]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1613</guid>
		<description><![CDATA[So there are a handful of webtools using Bookmarklets for their services. The first i know was del.icio.us for saving a Webpage to your del.icio.us bookmarks. Another famous service is Instapaper (it uses internally read it later pocket, but that is another Story). I have a special service in mind, i want to create using [...]]]></description>
			<content:encoded><![CDATA[<p>So there are a handful of webtools using <a target="_new" href="http://en.wikipedia.org/wiki/Bookmarklet">Bookmarklets</a> for their services. The first i know was del.icio.us for saving a Webpage to your del.icio.us bookmarks. Another famous service is <a target="_new" href="http://www.instapaper.com">Instapaper</a> (it uses internally <del datetime="2012-05-11T23:05:01+00:00">read it later</del> <a target="_new" href="http://getpocket.com/">pocket</a>, but that is another Story). I have a special service in mind, i want to create using a Bookmarklets, before i start, i played around with the Bookmarklet from Instapaper.</p>
<p>The Magic is just a normale HTML A Tag, in whith some javascript is embedded:</p>
<pre>
javascript:function%20iprl5(){var%20d=document,z=d.createElement('scr'+'ipt'),b=d.body,l=d.location;try{if(!b)throw(0);d.title='(Saving...)%20'+d.title;z.setAttribute('src',l.protocol+'//www.instapaper.com/j/foobar?u='+encodeURIComponent(l.href)+'&#038;t='+(new%20Date().getTime()));b.appendChild(z);}catch(e){alert('Please%20wait%20until%20the%20page%20has%20loaded.');}}iprl5();void(0)
</pre>
<p>If we unwrap that script we got</p>
<pre>
function iprl5(){
    var d=document,
    z=d.createElement('scr'+'ipt'),
    b=d.body,
    l=d.location;
    try{
        if(!b)
            throw(0);
        d.title='(Saving...) '+d.title;
        z.setAttribute('src',l.protocol+'//www.instapaper.com/j/foobar?u='+encodeURIComponent(l.href)+'&amp;t='+(new Date().getTime()));
        b.appendChild(z);
    }catch(e){
        alert('Please wait until the page has loaded.');
    }
}
iprl5();
void(0)
</pre>
<p>The command basically just creates a script tag in the active DOM-Tree and preloads some Javascript-File. The File is then executed by the Browsers JS Runtime.<br />
I started a litte Demo Project. You find it <a target="_new" href="https://github.com/phaus/annotate">here on GitHub</a>. It is based on Play! 1.2.4 (<a target="_new" href="http://www.playframework.org/documentation/1.2.4/install">Installation Guide here</a>).</p>
<p>ATM there are just two JS Templates. The first one (<em>app/views/Application/bookmarklet.js</em>) just contains the source for the Script-Tag itself. The second (<em>app/views/Application/input.js</em>) will be loaded then after the Javascript behinde that link is called.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/05/hacking-just-for-fun-using-bookmarklets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hacking just for Fun: Get Mails from IMAP with Java</title>
		<link>http://www.philipp.haussleiter.de/2012/04/hacking-just-for-fun-get-mails-from-imap-with-java/</link>
		<comments>http://www.philipp.haussleiter.de/2012/04/hacking-just-for-fun-get-mails-from-imap-with-java/#comments</comments>
		<pubDate>Tue, 03 Apr 2012 22:35:56 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1601</guid>
		<description><![CDATA[I have the feeling, that i might need this someday . Collecting Mails from an IMAP Server with Java is pretty easy: package de.javastream.imapcollector; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Properties; import javax.mail.Folder; import javax.mail.Message; import javax.mail.Multipart; import javax.mail.Part; import javax.mail.Session; import javax.mail.Store; import javax.mail.internet.MimeBodyPart; import javax.swing.JOptionPane; public class App { public static void getMail(String host, [...]]]></description>
			<content:encoded><![CDATA[<p>I have the feeling, that i might need this someday <img src='http://www.philipp.haussleiter.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>Collecting Mails from an IMAP Server with Java is pretty easy:</p>
<pre>
package de.javastream.imapcollector;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Part;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.internet.MimeBodyPart;
import javax.swing.JOptionPane;

public class App {

    public static void getMail(String host, String user, String passwd) throws Exception {
        Session session = Session.getDefaultInstance(new Properties());
        Store store = session.getStore("imap");
        store.connect(host, user, passwd);
        Folder folder = store.getFolder("INBOX");
        folder.open(Folder.READ_ONLY);
        // the funny part is... you can count all the messages before you download them.
        Message[] messages = folder.getMessages();
        System.out.println("there are "+messages.length+" in your INBOX.");
        for (int i = 0; i <; messages.length; i++) {
            Message m = messages[i];
            System.out.println("Nachricht: " + i);
            System.out.println("From: " + m.getFrom()[0]);
            System.out.println("Subject: " + m.getSubject());
            // some Messages are multipart messages (e.g. text with an attachement)
            if (m.getContentType().equals("multipart")) {
                Multipart mp = (Multipart) m.getContent();
                for (int j = 0; j <; mp.getCount(); j++) {
                    Part part = mp.getBodyPart(j);
                    String disposition = part.getDisposition();
                    if (disposition == null) {
                        MimeBodyPart mimePart = (MimeBodyPart) part;
                        if (mimePart.isMimeType("text/plain")) {
                            BufferedReader in = new BufferedReader(
                                    new InputStreamReader(mimePart.getInputStream()));
                            for (String line; (line = in.readLine()) != null;) {
                                System.out.println(line);
                            }
                        }
                    }
                }
            } else {
                System.out.println(m.getContent());
            }
        }
        System.out.println("done <img src='http://www.philipp.haussleiter.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ");
        folder.close(false);
        store.close();
    }

    public static void main(String[] args) throws Exception {
        // show some simple Dialogs to get server, username and password
        String server = JOptionPane.showInputDialog("enter your Mail Server e.g. mail.example.com");
        String user = JOptionPane.showInputDialog("enter your login e.g. user");
        String password = JOptionPane.showInputDialog("enter your mail password");
        getMail(server, user, password);
    }
}</pre>
<p>Becource you will need the java mail lib as a dependency i just created a small maven project to add them.<br />
Just unzip it and run</p>
<pre>mvn exec:java</pre>
<p>Download <a href="http://www.philipp.haussleiter.de/wp-content/uploads/2012/04/ImapCollector.zip">Maven Project for ImapCollector</a></p>
<p><strong>Update:</strong><br />
A College of mine asks for the imports of that Code. I just added them to the sources. You have to include the<a href="http://www.oracle.com/technetwork/java/javamail/index.html"> javamail lib from <del datetime="2012-04-04T09:55:35+00:00">Sun</del> Oracle</a> as a dependency to run the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/04/hacking-just-for-fun-get-mails-from-imap-with-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacking just for Fun: Raid5 in Java</title>
		<link>http://www.philipp.haussleiter.de/2012/03/hacking-just-for-fun-raid5-in-java/</link>
		<comments>http://www.philipp.haussleiter.de/2012/03/hacking-just-for-fun-raid5-in-java/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:43:06 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1596</guid>
		<description><![CDATA[I was just curious how easy it might be to write a RAID5 compatible Outputstream in Java? Just a few Lines. For sure it is not the most elegante solution. Especially if you see the nice possibility to integrate one Outputstream within another&#8230; so maybe two Raid5s into one Raid0 Stream? (would be RAID50) then. [...]]]></description>
			<content:encoded><![CDATA[<p>I was just curious how easy it might be to write a RAID5 compatible Outputstream in Java? Just a few Lines. For sure it is not the most elegante solution. Especially if you see the nice possibility to integrate one Outputstream within another&#8230; so maybe two Raid5s into one Raid0 Stream? (would be RAID50) then. Reading is missing <img src='http://www.philipp.haussleiter.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<pre>/**
 * Raid5Stream
 * 31.03.2012
 * @author Philipp Haussleiter
 *
 */
package de.javastream.jraid;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class Raid5Stream extends OutputStream {

    public final static int PARITY_MARKER = 1;
    public final static int DATA_MARKER = 0;
    private File disks[];
    private FileOutputStream streams[];
    private int mode = 0;
    private final static int MAX_MODE = 2;
    private int[] buffer = new int[2];

    public Raid5Stream(File disks[]) throws IOException {
        super();
        if (disks.length != 3) {
            throw new RuntimeException("we need a disk count of x times 3");
        }
        int i = 0;
        this.disks = new File[disks.length];
        this.streams = new FileOutputStream[disks.length];
        for (File f : disks) {
            if (!f.exists() &amp;&amp; !f.createNewFile()) {
                throw new RuntimeException(f.getAbsolutePath() + " does not exists and cannot be created!");
            } else {
                System.out.println("using " + f.getAbsolutePath() + "\n");
                this.disks[i] = f;
                this.streams[i] = new FileOutputStream(f);
            }
            i++;
        }
        writerMarker();
    }

    private void writerMarker() throws IOException {
        for (int i = 0; i &lt; this.streams.length; i++) {
            if (i % 3 == 0) {
                this.streams[i].write(PARITY_MARKER);
            } else {
                this.streams[i].write(DATA_MARKER);
            }
        }
    }

    @Override
    public void write(int i) throws IOException {
        switch (mode) {
            case MAX_MODE:
                this.streams[mode].write(buffer[0] ^ buffer[1]);
                mode = 0;
            default:
                this.buffer[mode] = i;
                this.streams[mode].write(i);
                mode++;
        }
    }
}</pre>
<p>Using it is easy as:</p>
<pre>...
public class App {

    public static void main(String[] args) throws IOException {
        File raid5_disk1 = new File("raid5.disk1");
        File raid5_disk2 = new File("raid5.disk2");
        File raid5_disk3 = new File("raid5.disk3");
        long count = 0;
        Raid5Stream raid5Stream = new Raid5Stream(new File[]{raid5_disk1, raid5_disk2, raid5_disk3});
        FileInputStream in = new FileInputStream("/dev/random");
        BufferedInputStream bis = new BufferedInputStream(in);
        BufferedOutputStream raid5bos = new BufferedOutputStream(raid5Stream);
        while(count &lt; 1024*1024*2){
            raid5bos.write(bis.read());
            count++;
        }
        raid5bos.close();
        bis.close();
    }
}</pre>
<p>Good sources for more reading are the Wikipedia Articles about <a href="http://en.wikipedia.org/wiki/RAID">RAID</a> and <a href="http://en.wikipedia.org/wiki/XOR">XOR</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/03/hacking-just-for-fun-raid5-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVG &#8211; the lost son of formats</title>
		<link>http://www.philipp.haussleiter.de/2012/03/svg-the-lost-son-of-formats/</link>
		<comments>http://www.philipp.haussleiter.de/2012/03/svg-the-lost-son-of-formats/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 22:59:53 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[Edu]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Tooling]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1591</guid>
		<description><![CDATA[I was on the Chemnitz Linux Days last weekend. Besides great other talks a saw &#8220;Free your slides – Vortragsfolien im Browser anzeigen&#8221; from Sirko Kemter. He talked about a tiny tool called jessyink for creating Slides out of inkscape SVGs. I did a small SVG-Demo some months ago using RaphaelJS and a draft about [...]]]></description>
			<content:encoded><![CDATA[<p>I was on the<a href="http://chemnitzer.linux-tage.de/2012/"> Chemnitz Linux Days</a> last weekend. Besides great other talks a saw &#8220;Free your slides – Vortragsfolien im Browser anzeigen&#8221; from Sirko Kemter. He talked about a tiny tool called <a href="http://code.google.com/p/jessyink/">jessyink</a> for creating Slides out of inkscape SVGs. I did a small <a href="http://demo.hausswolff.de/jsGraph/">SVG-Demo</a> some months ago using <a href="http://raphaeljs.com/">RaphaelJS</a> and a draft about this project exists since then. So instead of trying to complete this draft and published it, i decided to ask what area of SVG might be of interest here. Basic SVG elements? Animation? It might need some time, but i re-discovered what a great format SVG is and really want to create some posts for that.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/03/svg-the-lost-son-of-formats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run local/remote terminal commands with java using ssh</title>
		<link>http://www.philipp.haussleiter.de/2012/03/run-localremote-terminal-commands-with-java-using-ssh/</link>
		<comments>http://www.philipp.haussleiter.de/2012/03/run-localremote-terminal-commands-with-java-using-ssh/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 22:50:15 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Play! Framework]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1584</guid>
		<description><![CDATA[Sometimes you need to use some CLI-Tools before you want to create or search for a native JNI Binding. So there is a common way, using the Java Process-Class. But then you might meet two problems i had to face in the past during several problems: There are (a really small) number of CLI-Tools, that [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to use some CLI-Tools before you want to create or search for a native JNI Binding.<br />
So there is a common way, using the Java <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Process.html" target="_new">Process-Class</a>. But then you might meet two problems i had to face in the past during several problems:</p>
<ol>
<li>There are (a really small) number of CLI-Tools, that giving no constant output over the STD-OUT (the standard output the Process-Class uses for output)</li>
<li>There is no <a href="http://programmers.stackexchange.com/questions/97912/how-do-you-define-elegant-code" target="_new">&#8220;elegant&#8221;</a> way to implement a process call into your project.</li>
</ol>
<p>To solve this Problem I created a basic HelperClass, that calls the System over SSH (with the Convenience to work remote and the side-effect to always get STD-compatible output).<br />
I am primarely using it for a fun project <a href="https://github.com/phaus/sam">SAM</a> i started some months ago to try to create a Management-Tool for Unices and Windows with a very low client-side footprint.</p>
<p>The first Class is used to capsulate the basic SSH Calls:<br />
<code>
<pre>
// some imports...
 public class SystemHelper {
    private Runtime r;
    private String sshPrefix = "";

    // call with $user and 127.0.0.1 to run local command.
    public SystemHelper(String user, String ip) {
        r = Runtime.getRuntime();
        sshPrefix = " ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " + user + "@" + ip;
    }

    public void runCommand(String command, ProcessParser pp) {
        try {
            Logger.info("running: " + this.sshPrefix + " " + command);
            Process p = r.exec(this.sshPrefix + " " + command);
            InputStream in = p.getInputStream();
            BufferedInputStream buf = new BufferedInputStream(in);
            InputStreamReader inread = new InputStreamReader(buf);
            BufferedReader bufferedreader = new BufferedReader(inread);
            pp.parse(bufferedreader);
            try {
                if (p.waitFor() != 0) {
                    Logger.info("exit value = " + p.exitValue());
                }
            } catch (InterruptedException e) {
                System.err.println(e);
            } finally {
                // Close the InputStream
                bufferedreader.close();
                inread.close();
                buf.close();
                in.close();
            }
        } catch (IOException ex) {
            Logger.error(ex.getLocalizedMessage());
        }
    }
}
</pre>
<p></code></p>
<p>ProcessParser is an interface that defines the methode parse, accepting a BufferedReader for parsing the output of the Process. Unfortunately there is no timeout ATM to kill a hanging SSH-Call.</p>
<p><code>
<pre>
 public interface ProcessParser {
     public void parse(BufferedReader bufferedreader);
 }
</pre>
<p></code></p>
<p>The most basic (Output-)Parser looks like this:</p>
<p><code>
<pre>
    public String getPublicSSHKey() {
        SimpeOutputPP so = new SimpeOutputPP();
        String command = "cat ~/.ssh/id_rsa.pub";
        runCommand(command, so);
        if (!so.getOutput().isEmpty()) {
            return so.getOutput().get(0);
        }
        return "";
    }
</pre>
<p></code></p>
<p>This returns just the public SSH-Key of the current user. I implemented some more parsers for the output of apt (dpkg), rpm and pacman. You can find them <a href="https://github.com/phaus/sam/tree/master/app/helper/unix/parser" target="_blank">in the github project here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/03/run-localremote-terminal-commands-with-java-using-ssh/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Blog Design update</title>
		<link>http://www.philipp.haussleiter.de/2012/02/blog-design-update/</link>
		<comments>http://www.philipp.haussleiter.de/2012/02/blog-design-update/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 01:13:50 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1567</guid>
		<description><![CDATA[After endless years of using the old classic WordPress Theme, i started to creating my own Theming. So it might be a little bit edgy round the corners during the next days . Thank you to falkh for giving me a basic start with the nice Post-Caption-Thingys .]]></description>
			<content:encoded><![CDATA[<p>After endless years of using the old classic WordPress Theme, i started to creating my own Theming. So it might be a little bit edgy round the corners during the next days <img src='http://www.philipp.haussleiter.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Thank you to falkh for giving me a basic start with the nice Post-Caption-Thingys <img src='http://www.philipp.haussleiter.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/02/blog-design-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counter Update</title>
		<link>http://www.philipp.haussleiter.de/2012/02/counter-update-2/</link>
		<comments>http://www.philipp.haussleiter.de/2012/02/counter-update-2/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 15:20:52 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[DB]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Play! Framework]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1556</guid>
		<description><![CDATA[I just finished my latest improvements to the legacy version of my counter script. I just added the lookup for ISPs and added dynamic scaling for the axis legend. I will now going forward to change the whole system to a more sophisticated software, e.g. using a Datawarehouse approach. The first version of the Data-Model [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished my latest improvements to the legacy version of my counter script.<br />
I just added the lookup for ISPs and added dynamic scaling for the axis legend.<br />
I will now going forward to change the whole system to a more sophisticated software, e.g. using a Datawarehouse approach. The first version of the Data-Model is finished.</p>
<p>So from the old version (that was just some plain tables, flowing around)</p>
<p><a href="http://www.philipp.haussleiter.de/wp-content/uploads/2012/02/old-counter.png"><img class="size-medium wp-image-1557 alignleft" title="old-counter" src="http://www.philipp.haussleiter.de/wp-content/uploads/2012/02/old-counter-300x275.png" alt="" width="300" height="275" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>I created a new Model with more Tables, connected to each other. Basically i devided the Model into a basic Fact (Count) and some Dimensions (for every Value):</p>
<p><a href="http://www.philipp.haussleiter.de/wp-content/uploads/2012/02/play-counter.png"><img class="alignleft size-medium wp-image-1558" title="play-counter" src="http://www.philipp.haussleiter.de/wp-content/uploads/2012/02/play-counter-261x300.png" alt="" width="261" height="300" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>With my current values (around 22k Facts), i have already to limit the facts that are queryed from the Datebase. I wrote a short script to migrate all old Datasets to the new Data-Model.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/02/counter-update-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joyent SmartOS Mysql VM Setup</title>
		<link>http://www.philipp.haussleiter.de/2012/02/joyent-smartos-mysql-vm-setup/</link>
		<comments>http://www.philipp.haussleiter.de/2012/02/joyent-smartos-mysql-vm-setup/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 21:05:07 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[Tooling]]></category>
		<category><![CDATA[Virtualisierung]]></category>
		<category><![CDATA[SmartOS]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1550</guid>
		<description><![CDATA[I just played around with the new SmartOS from Joyent ( Homepage ). I followed a basic tutorial from a Blog called opusmagnus to setup my basic SmartOS Machine on Virtualbox. You basically just have to insert the latest iso image and startup the VM (SmartOS is a system that runs from a live Medium [...]]]></description>
			<content:encoded><![CDATA[<p>I just played around with the new SmartOS from Joyent ( <a title="smartos Product Page" href="http://smartos.org / http://www.joyent.com/products/smartos">Homepage</a> ). I followed a basic tutorial from a Blog called <a href="http://opusmagnus.wordpress.com">opusmagnus</a> to setup my basic SmartOS Machine on Virtualbox. You basically just have to insert the latest iso image and startup the VM (SmartOS is a system that runs from a live Medium &#8211; an DVD- or USB Image, so all your harddisk belongs to your VMs).</p>
<p>I will just summarize the basic steps to setup a basic VM for Mysql (you should also read the original post <a title="Discovering SmartOS" href="http://opusmagnus.wordpress.com/2012/02/14/discovering-smartos/" target="_blank">here</a>).<br />
After you installed your VM (setup Networking/ZFS Pool &#8211; you should use &gt;3 virtual harddisks), you login into your new system and perfom the following steps:</p>
<p>Check for VM-Templates to install:</p>
<pre># dsadm avail
UUID                                 OS      PUBLISHED  URN
9dd7a770-59c7-11e1-a8f6-bfd6347ab0a7 smartos 2012-02-18 sdc:sdc:percona:1.3.8
467ca742-4873-11e1-80ea-37290b38d2eb smartos 2012-02-14 sdc:sdc:smartos64:1.5.3
7ecb80f6-4872-11e1-badb-3f567348a4b1 smartos 2012-02-14 sdc:sdc:smartos:1.5.3
1796eb3a-48d3-11e1-94db-3ba91709fad9 smartos 2012-01-27 sdc:sdc:riak:1.5.5
86112bde-43c4-11e1-84df-8f7fd850d78d linux   2012-01-25 sdc:sdc:centos6:0.1.1
...
5fef6eda-05f2-11e1-90fc-13dac5e4a347 smartos 2011-11-03 sdc:sdc:percona:1.2.2
d91f80a6-03fe-11e1-8f84-df589c77d57b smartos 2011-11-01 sdc:sdc:percona:1.2.1
...
9199134c-dd79-11e0-8b74-1b3601ba6206 smartos 2011-09-12 sdc:sdc:riak:1.4.1
3fcf35d2-dd79-11e0-bdcd-b3c7ac8aeea6 smartos 2011-09-12 sdc:sdc:mysql:1.4.1
...
7456f2b0-67ac-11e0-b5ec-832e6cf079d5 smartos 2011-04-15 sdc:sdc:nodejs:1.1.3
febaa412-6417-11e0-bc56-535d219f2590 smartos 2011-04-11 sdc:sdc:smartos:1.3.12</pre>
<p>I choose a percona VM (that is a VM with MySQL and some Backup Stuff pre-install &#8211; more <a title="Percona SmartMachine" href="http://www.joyentcloud.com/products/purpose-built-appliances/percona-smartmachine/" target="_blank">here</a>).</p>
<pre># dsadm import  a9380908-ea0e-11e0-aeee-4ba794c83c33
a9380908-ea0e-11e0-aeee-4ba794c83c33 doesnt exist. continuing with install
a9380908-ea0e-11e0-aeee-4ba794c83c33 successfully installed</pre>
<p>Then you need to create a basic VM-Config file <em>/tmp/percona-vm</em>:</p>
<pre>{
        "alias": "percona-vm",
        "brand": "joyent",
        "dataset_uuid": "a9380908-ea0e-11e0-aeee-4ba794c83c33",
        "dns_domain": "haussleiter.de",
        "quota": "10",
        "nics": [
                {
                        "nic_tag": "admin",
                        "ip": "192.168.178.42",
                        "netmask": "255.255.255.0",
                        "gateway": "192.168.178.1"
                }
        ]
}</pre>
<p>You are now able to create your VM:</p>
<pre># vmadm create -f /tmp/percona-vm
Successfully created df4108a7-c3af-4372-b959-6066c70661e9</pre>
<p>You can check if your new VM is running:</p>
<pre># vmadm list
UUID                                  TYPE  RAM      STATE             ALIAS
df4108a7-c3af-4372-b959-6066c70661e9  OS    256      running           percona-vm

# ping 192.168.178.42
192.168.178.42 is alive</pre>
<p>You can login in your VM (that is a Zone to be precisely with the zlogin command):</p>
<pre># zlogin df4108a7-c3af-4372-b959-6066c70661e9
[Connected to zone 'df4108a7-c3af-4372-b959-6066c70661e9' pts/2]</pre>
<p>Becourse i could not found any information about the predifined MySQL Password, i just change it using standard-Mylsq CMDs:<br />
First you need to stop the Mysql Service:</p>
<pre># svcadm disable mysql:percona</pre>
<p>Then you need to start Mysql again with skipping the tables for user-credentials.</p>
<pre># mysqld_safe --skip-grant-tables &amp;</pre>
<p>Enter Mysql CMD-Tools and change the root Password:</p>
<pre># mysql -uroot
mysql&gt; use mysql;
mysql&gt; update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql&gt; flush privileges;
mysql&gt; quit;</pre>
<p>You need to shutdown your MySQL instance:</p>
<pre># prstat
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
...
 10921 root     4060K 3016K cpu2     1    0   0:00:00 0.0% prstat/1
 10914 root     3200K 2236K sleep    1    0   0:00:00 0.0% bash/1
 10913 root     3172K 2244K sleep    1    0   0:00:00 0.0% login/1
<strong> 10894 mysql 207M 37M sleep 1 0 0:00:00 0.0% mysqld/27</strong>
...</pre>
<pre>kill 10894</pre>
<p>You now can start the MySQL Daemon again.</p>
<pre># svcadm enable mysql:percona</pre>
<p>I hope i will have time to look into more features of SmartOS. It seems to be a great System to Virtualize a lot of differend Service. It also supports virtualizing Windows VMs with KVM.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/02/joyent-smartos-mysql-vm-setup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Counter Update</title>
		<link>http://www.philipp.haussleiter.de/2012/02/counter-update/</link>
		<comments>http://www.philipp.haussleiter.de/2012/02/counter-update/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 00:47:40 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1547</guid>
		<description><![CDATA[Before i will do the great update of my counter script (i plan to switch to Java/Play with some basic DWH Features), i just added some dynamic webpage screen rendering based on thumbalizr (have a look here)]]></description>
			<content:encoded><![CDATA[<p>Before i will do the great update of my counter script (i plan to switch to Java/Play with some basic DWH Features), i just added some dynamic webpage screen rendering based on <a href="http://www.thumbalizr.com">thumbalizr</a> (have a look <a href="http://counter.consolving.de">here</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/02/counter-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running a Rails 3 Application in a Sub-URI Enviroment</title>
		<link>http://www.philipp.haussleiter.de/2012/02/running-a-rails-3-application-in-a-sub-uri-enviroment/</link>
		<comments>http://www.philipp.haussleiter.de/2012/02/running-a-rails-3-application-in-a-sub-uri-enviroment/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 23:07:31 +0000</pubDate>
		<dc:creator>philipp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.philipp.haussleiter.de/?p=1541</guid>
		<description><![CDATA[Sometimes you need to run your Rails (3) Application on a Sub-URI (e.g. examle.com/prod, example.com/dev). In my current Project there was a Problem with that Configuration and the Rails url-helpers (link_for, url_for, usw.) becourse the app wasn&#8217;t aware of the necessary prefix (in our example &#8220;/dev&#8221;, &#8220;/prod&#8221;). There is always the possibility to set the [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to run your Rails (3) Application on a Sub-URI (e.g. examle.com/prod, example.com/dev). In my current Project there was a Problem with that Configuration and the Rails url-helpers (link_for, url_for, usw.) becourse the app wasn&#8217;t aware of the necessary prefix (in our example &#8220;/dev&#8221;, &#8220;/prod&#8221;).</p>
<p>There is always the possibility to set the apps basic URL within your app-Context. Together with setting the prefix in a System Enviroment it was possible to achieve the wanted app behaviour.<br />
How to configure a Rails3 App with Passenger in a Sub-URI Configuration please have a look in the Phusion Passenger users guide <a href="http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rails_to_sub_uri">here</a> or in another blog post <a href="http://robots.thoughtbot.com/post/159806388/phusion-passenger-with-a-prefix">here</a>.</p>
<p>The Basic Apache Configuration looks somehow like this:</p>
<pre>&lt;VirtualHost *:80&gt;
    ServerName      example.com
    ServerAdmin     admin@example.com
    DocumentRoot    /var/www
    # we added two file hardlinks from our apps public folder to <em>/var/www/dev</em>,  <em>/var/www/prod</em>
        &lt;Directory <em>/var/www/prod</em>&gt;
        ...
        SetEnv RAILS_RELATIVE_URL_ROOT /prod
        ...
    &lt;/Directory&gt;
        &lt;Directory <em>/var/www/dev</em>&gt;
        ...
        SetEnv RAILS_RELATIVE_URL_ROOT /dev
        ...
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre>
<p>The last part is to add a Before-Hook to the <em>ApplicationController</em> for updating the apps default_url if <em>RAILS_RELATIVE_URL_ROOT</em> is set:</p>
<pre>class ApplicationController &lt; ActionController::Base
  protect_from_forgery

  before_filter :action_set_url_options

  def action_set_url_options
    if ENV['RAILS_RELATIVE_URL_ROOT']
      @host = request.host+":"+request.port.to_s+"/"+ENV['RAILS_RELATIVE_URL_ROOT']
    else
      @host = request.host+":"+request.port.to_s
    end
    Rails.application.routes.default_url_options = { :host =&gt; @host}
  end
end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.philipp.haussleiter.de/2012/02/running-a-rails-3-application-in-a-sub-uri-enviroment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

