<?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>devl.net &#187; Misc</title>
	<atom:link href="http://devl.net/category/programming/misc/feed/" rel="self" type="application/rss+xml" />
	<link>http://devl.net</link>
	<description>/home/devl/</description>
	<lastBuildDate>Wed, 20 Jan 2010 14:49:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Irssi Plugin: auto reply</title>
		<link>http://devl.net/2009/09/irssi-plugin-auto-reply/</link>
		<comments>http://devl.net/2009/09/irssi-plugin-auto-reply/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 14:43:52 +0000</pubDate>
		<dc:creator>sYnie</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Tips 'n Tricks]]></category>

		<guid isPermaLink="false">http://devl.net/?p=262</guid>
		<description><![CDATA[Some days ago I wrote a small irssi plugin, which automatically replies to specific words or phrases. It&#8217;s really basic, but I thought to post it anyway, as I couldn&#8217;t find any.
It&#8217;s based on the 8-ball plugin &#8211; so thanks to Patrik Jansson.
That&#8217;s the code:

use strict;

use vars qw($VERSION %IRSSI);
use Irssi qw(command_bind signal_add);

$VERSION = '1.00';
%IRSSI = [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I wrote a small irssi plugin, which automatically replies to specific words or phrases. It&#8217;s really basic, but I thought to post it anyway, as I couldn&#8217;t find any.</p>
<p>It&#8217;s based on the 8-ball plugin &#8211; so thanks to Patrik Jansson.</p>
<p>That&#8217;s the code:</p>
<pre>
use strict;

use vars qw($VERSION %IRSSI);
use Irssi qw(command_bind signal_add);

$VERSION = '1.00';
%IRSSI = (
    authors     => 'synie',
    name        => 'auto reply',
    description => 'auto reply',
    license     => 'GPL',
);

sub own_question {
    my ($server, $msg, $target) = @_;
    question($server, $msg, "", $target);
}

sub public_question {
    my ($server, $msg, $nick, $address, $target) = @_;
    question($server, $msg, $nick, $target);
}

sub question($server, $msg, $nick, $target) {
    my ($server, $msg, $nick, $target) = @_;
    $_ = $msg;
    my $answer = "";

    // Edit this:
    if (/^how are you?/i) {
        $answer = "I'm fine, thanks.";
    } elsif (/ping/i) {
        $answer = "pong";
    } elsif (/^I hate you/i) {
        if ($nick ne "fishbot" and $nick ne "snailbot")
        {
            $server->command('kick '.$target.' '.$nick.' bye!');
            return 0;
        }
    }

    if ($answer)
    {
        $server->command('msg '.$target.' '.($nick ? $nick.': ' : '').$answer);
    }
    return 0;
}

signal_add("message public", "public_question");
signal_add("message own_public", "own_question");
</pre>
<p>Just c&amp;p it into a file (e.g. called autoreply) located at ~/.irssi/scripts or ~/.irssi/scripts/autorun and load it via `/script load autoreply`. Make sure you edited the phrases you want to answer to automatically first &#8211; but I think this script is self-explanatory.</p>
]]></content:encoded>
			<wfw:commentRss>http://devl.net/2009/09/irssi-plugin-auto-reply/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Visual Basic .Net block text justification</title>
		<link>http://devl.net/2007/06/visual-basic-net-blocksatz/</link>
		<comments>http://devl.net/2007/06/visual-basic-net-blocksatz/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 13:47:31 +0000</pubDate>
		<dc:creator>sYnie</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.synie.net/?p=33</guid>
		<description><![CDATA[I&#8217;m working on a project where I have to use VB.NET to render some text. The problem is, that VB doesn&#8217;t provite block text justification by default. Using GDI+ it&#8217;s quite easy to get that managed. The resulting text will be displayed on a bitmap, which can be drawn to a picturebox etc. Here&#8217;s the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a project where I have to use VB.NET to render some text. The problem is, that VB doesn&#8217;t provite block text justification by default. Using GDI+ it&#8217;s quite easy to get that managed. The resulting text will be displayed on a bitmap, which can be drawn to a picturebox etc. Here&#8217;s the code:</p>
<blockquote><p>Sub BlockJustification(ByRef pic As Bitmap, ByVal txt As String, ByRef x As Short, ByRef y As Short, ByRef w As Short)<br />
Dim g As Graphics<br />
g = Graphics.FromImage(pic)</p>
<p>Dim fnt As New Font(&#8221;Times New Roman&#8221;, 10)<br />
Dim cnty As Integer = 0</p>
<p>Dim ar As String() = txt.Split(Chr(10) + Chr(13))<br />
For m As Integer = 0 To UBound(ar)<br />
Dim newTxt As String = &#8220;&#8221;<br />
Dim array As String() = ar(m).Split(&#8221; &#8220;)<br />
For i As Integer = 0 To UBound(array)<br />
Dim newTxtTmp As String = newTxt + array(i)</p>
<p>If g.MeasureString(newTxtTmp, fnt, 9999999).Width &gt;= w Then<br />
Dim spacearray As String() = newTxt.Split(&#8221; &#8220;)<br />
Dim spacecnt As Integer = UBound(spacearray) &#8211; 1</p>
<p>If spacecnt &lt; 1 Then<br />
newTxt = newTxtTmp<br />
Dim tobreake As String = &#8220;&#8221;<br />
Do While True<br />
If g.MeasureString(tobreake, fnt, 9999999).Width &gt;= w Then<br />
g.DrawString(tobreake, fnt, Brushes.Black, 0, cnty)<br />
cnty += 15<br />
tobreake = &#8220;&#8221;<br />
If g.MeasureString(newTxt, fnt, 9999999).Width &lt; = w Then<br />
newTxt += &#8221; &#8221;<br />
Exit Do<br />
End If<br />
End If<br />
tobreake += newTxt.Substring(0, 1)<br />
newTxt = newTxt.Substring(1, newTxt.Length &#8211; 1)<br />
Loop<br />
Else<br />
Dim newTxtlength As Integer = 0<br />
For n As Integer = 0 To UBound(spacearray) &#8211; 1<br />
newTxtlength += g.MeasureString(spacearray(n), fnt, 9999999).Width<br />
Next<br />
Dim space As Integer = w &#8211; newTxtlength<br />
Dim spaceperword As Integer = space / spacecnt<br />
Dim cntmeasure As Integer = 0<br />
Dim dotcnt As Integer = w &#8211; (newTxtlength + (spaceperword * spacecnt))<br />
&#8216;MsgBox(&#8221;space: &#8221; + space.ToString + &#8221; &#8212; wordspace: &#8221; + spaceperword.ToString + &#8221; &#8212; measure: &#8221; + newTextlength.ToString + &#8221; &#8212; width: &#8221; + w.ToString + &#8221; &#8212; spacecnt: &#8221; + spacecnt.ToString + &#8221; &#8212; dotcnt: &#8221; + dotcnt.ToString + &#8221; &#8212; txt: &#8216;&#8221; + newTxt + &#8220;&#8216;&#8221;)<br />
For n As Integer = 0 To UBound(spacearray) &#8211; 1<br />
g.DrawString(spacearray(n), fnt, Brushes.Black, cntmeasure, cnty)<br />
If n = 0 Then<br />
cntmeasure = cntmeasure + dotcnt<br />
End If<br />
cntmeasure += g.MeasureString(spacearray(n), fnt, 9999999).Width + spaceperword<br />
Next<br />
g.DrawLine(Pens.Blue, cntmeasure &#8211; spaceperword, 0, cntmeasure &#8211; spaceperword, 300)<br />
i -= 1<br />
newTxt = &#8220;&#8221;<br />
cnty += 15<br />
End If<br />
Else<br />
newTxt += array(i) + &#8221; &#8221;<br />
End If<br />
Next<br />
If Not newTxt = &#8220;&#8221; Then<br />
g.DrawString(newTxt, fnt, Brushes.Black, 0, cnty)<br />
cnty += 15<br />
End If<br />
Next<br />
g.Dispose()<br />
End Sub</p></blockquote>
<p>Now you can use it like this:</p>
<blockquote><p>Dim img As New Bitmap(500, 500)<br />
BlockJustification(img, Text1.Text, 0, 0, 250)<br />
PictureBox1.CreateGraphics.DrawImage(img, 0, 0)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://devl.net/2007/06/visual-basic-net-blocksatz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
