<?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>/dev/tty &#187; Uncategorized</title>
	<atom:link href="http://blog.tty.nl/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tty.nl</link>
	<description>Notes on Web Development, Computer Programming, and Software Engineering</description>
	<lastBuildDate>Fri, 03 Sep 2010 11:44: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>Solr DataImportHandler issue: positive integers indexed for string &#8216;nested&#8217; fields</title>
		<link>http://blog.tty.nl/2010/06/23/solr-dataimporthandler-issue-positive-integers-indexed-for-string-nested-fields/</link>
		<comments>http://blog.tty.nl/2010/06/23/solr-dataimporthandler-issue-positive-integers-indexed-for-string-nested-fields/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 12:43:53 +0000</pubDate>
		<dc:creator>Ward Bekker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tty.nl/?p=392</guid>
		<description><![CDATA[A quick note about a Solr issue that took me some time to solve.
If this sounds familiar&#8230;.

You are using the DataImportHandler for Solr
You have a entity with a field which values come from a related entity.
After an import it looks like Solr only indexed even postive integers if you look at the schema browser.

&#8230;.You probably [...]]]></description>
			<content:encoded><![CDATA[<p>A quick note about a <a href="http://lucene.apache.org/solr/">Solr</a> issue that took me some time to solve.</p>
<p>If this sounds familiar&#8230;.</p>
<ul>
<li>You are using the <a href="http://wiki.apache.org/solr/DataImportHandler">DataImportHandler for Solr</a></li>
<li>You have a entity with a field which values come from a related entity.</li>
<li>After an import it looks like Solr only indexed even postive integers if you look at the schema browser.</ul>
</ul>
<p>&#8230;.You probably have a &#8216;nested&#8217; field which name is similar to it&#8217;s entity name. See the code below: entity name = regio and field name = regio. Changing field name to something else (regions) solved the issue. When you think about it, it&#8217;s somewhat logical that you don&#8217;t allow field names to have the same name as the entity. An schema exception during indexing would have been nice though.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;dataConfig&gt;<br />
&lt;dataSource type=&quot;JdbcDataSource&quot; driver=&quot;com.mysql.jdbc.Driver&quot; url=&quot;jdbc:mysql://localhost/nvb?zeroDateTimeBehavior=convertToNull&quot; user=&quot;****&quot; password=&quot;****&quot;/&gt;<br />
&nbsp; &nbsp; &lt;document name=&quot;vacatures&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;entity name=&quot;vacature&quot; query=&quot;select * from vacature&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field column=&quot;id&quot; name=&quot;id&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;entity name=&quot;regio&quot; query=&quot;SELECT regio from foo where vacature='${vacature.id}&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;regio&quot; column=&quot;regio&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/entity&gt;</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tty.nl/2010/06/23/solr-dataimporthandler-issue-positive-integers-indexed-for-string-nested-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MongoDB first impressions</title>
		<link>http://blog.tty.nl/2010/02/08/mongodb-first-impressions/</link>
		<comments>http://blog.tty.nl/2010/02/08/mongodb-first-impressions/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 11:40:24 +0000</pubDate>
		<dc:creator>Ward Bekker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tty.nl/?p=323</guid>
		<description><![CDATA[For a customer we have developed log analytics software. It’s currently uses MYSQL as the database backend. The system reads in a hourly log file, and calculates all kinds of fancy statistics. I wanted to see how the system would work if I used MongoDB, a schema-less document DB, instead of MYSQL. My impressions in no [...]]]></description>
			<content:encoded><![CDATA[<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">For a customer we have developed log analytics software. It’s currently uses MYSQL as the database backend. The system reads in a hourly log file, and calculates all kinds of fancy statistics. I wanted to see how the system would work if I used <a href="http://www.mongodb.org">MongoDB</a>, a schema-less document DB, instead of MYSQL. My impressions in no particular order:</span></p>
<ul>
<li style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">Importing log data is much easier than on MYSQL because MongoDB is schema-less. Just create a collection (=bucket) and insert every log line into it as a hash. For log files that don&#8217;t have a fixed amount of fields, it&#8217;s a great fit.</span></li>
<li style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">Like MYSQL, you do need to create indexes to make searching fast(er). </span></li>
<li style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">MongoDB supports map reduce operations. It made some of the calculations much more elegant and better readable than the code that was written for MYSQL.</span></li>
<li style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">Chaining of map reduce operations is supported, and works as you would expect.</span></li>
<li style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">Queries are written in javascript. I&#8217;m happy that they didn&#8217;t invent yet another &#8217;scripting&#8217; language. Javascript looks capable enough. </span></li>
<li style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">Map reduce operations are not particularly fast. They are upgrading their javascript engine to <a href="http://jira.mongodb.org/browse/SERVER-446">V8</a> to improve the execution speed. </span></li>
<li style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">MongoDB community is nowhere near the size of MYSQL. Don’t expect a lot of Google results for a specific mongoDB issue. <a href="http://groups.google.com/group/mongodb-user">The moderated Google group</a> is a better place to go currently. </span></li>
<li style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">I liked the API. Calls are not verbose and their intented use is easy to understand.</span></li>
<li style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;"><span style="letter-spacing: 0.0px;">Although quite capable, mongoDB is still a young project. I need to have more time with it before using it on a customer project.</span></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.tty.nl/2010/02/08/mongodb-first-impressions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ruby Quiz, Haskell Solution: LCD Numbers</title>
		<link>http://blog.tty.nl/2009/12/17/ruby-quiz-haskell-solution-lcd-numbers/</link>
		<comments>http://blog.tty.nl/2009/12/17/ruby-quiz-haskell-solution-lcd-numbers/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 13:26:34 +0000</pubDate>
		<dc:creator>Michel Rijnders</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Ruby Quiz]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tty.nl/?p=288</guid>
		<description><![CDATA[A solution to Ruby Quiz #14 in literate Haskell:

LCD Numbers
===========

Problem
-------

[original source](http://rubyquiz.com/quiz14.html)

This week's quiz is to write a program that displays LCD style numbers
at adjustable sizes.

The digits to be displayed will be passed as an argument to the
program. Size should be controlled with the command-line option -s
follow up by a positive integer. The default value for [...]]]></description>
			<content:encoded><![CDATA[<p>A solution to Ruby Quiz #14 in literate Haskell:</p>
<pre>
LCD Numbers
===========

Problem
-------

[original source](http://rubyquiz.com/quiz14.html)

This week's quiz is to write a program that displays LCD style numbers
at adjustable sizes.

The digits to be displayed will be passed as an argument to the
program. Size should be controlled with the command-line option -s
follow up by a positive integer. The default value for -s is 2.

For example, if your program is called with:

    $ lcd.rb 012345

The correct display is:

     --        --   --        --
    |  |    |    |    | |  | |
    |  |    |    |    | |  | |
               --   --   --   --
    |  |    | |       |    |    |
    |  |    | |       |    |    |
     --        --   --        -- 

And for:

    $ lcd.rb -s 1 6789

Your program should print:

     -   -   -   -
    |     | | | | |
     -       -   -
    | |   | | |   |
     -       -   - 

Note the single column of space between digits in both examples. For
other values of -s, simply lengthen the - and | bars.

Solution
--------

Module declaration and imports:

> module Main where
>
> import Data.Char (digitToInt)
> import Data.List (intersperse)
> import System.Console.GetOpt
> import System.Environment (getArgs)

First we define the numbers at size 1:

> n0 = [ " - "
>      , "| |"
>      , "   "
>      , "| |"
>      , " - "
>      ]
>
> n1 = [ "   "
>      , "  |"
>      , "   "
>      , "  |"
>      , "   "
>      ]
>
> n2 = [ " - "
>      , "  |"
>      , " - "
>      , "|  "
>      , " - "
>      ]
>
> n3 = [ " - "
>      , "  |"
>      , " - "
>      , "  |"
>      , " - "
>      ]
>
> n4 = [ "   "
>      , "| |"
>      , " - "
>      , "  |"
>      , "   "
>      ]
>
> n5 = [ " - "
>      , "|  "
>      , " - "
>      , "  |"
>      , " - "
>      ]
>
> n6 = [ " - "
>      , "|  "
>      , " - "
>      , "| |"
>      , " - "
>      ]
>
> n7 = [ " - "
>      , "  |"
>      , "   "
>      , "  |"
>      , "   "
>      ]
>
> n8 = [ " - "
>      , "| |"
>      , " - "
>      , "| |"
>      , " - "
>      ]
>
> n9 = [ " - "
>      , "| |"
>      , " - "
>      , "  |"
>      , " - "
>      ]
>

Put the numbers in  a list:

> numbers = [n0,n1,n2,n3,n4,n5,n6,n7,n8,n9]

Horizontal scaling function, given a string replicate the second
character n times:

> hscale n cs = head cs : replicate n (cs!!1) ++ [last cs]

Vertical scaling function, repeat the second and fourth row n times:

> vscale n css = head css : replicate n cs1 ++ [cs2] ++ replicate n cs3 ++ [cs4]
>   where cs1 = css !! 1
>         cs2 = css !! 2
>         cs3 = css !! 3
>         cs4 = last css

Scale function; note this function scales a single number:

> scale n = vscale n . map (hscale n)

Function that converts a list of numbers to a string of LCD numbers:

> lcd n = concat .
>         intersperse "\n" .
>         foldr1 (zipWith (++)) .
>         intersperse (replicate (3 + 2*n) " ") .
>         map (scale n . (numbers !!))

`main` function:

> main = do
>   args <- getArgs
>   let (n, digits) = parseArgs args
>   putStrLn $ lcd n $ map digitToInt digits

Command-line argument parsing:

> data Flag = Scale Int
>             deriving Eq
>
> options = [Option "s" [] (ReqArg (Scale . read) "") ""]
>
> parseArgs args =
>   case parse args of
>    (_, [], _)              -> error "Usage: lcd [-s n] digits"
>    ([], digits, [])        -> (2, head digits)
>    ([Scale n], digits, []) -> (n, head digits)
>    (_, _, _)               -> error "Usage: lcd [-s n] digits"
>   where
>     parse = getOpt RequireOrder options
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.tty.nl/2009/12/17/ruby-quiz-haskell-solution-lcd-numbers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
