<?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>ejs &#187; programming</title>
	<atom:link href="http://ejs.seniejitrakai.net/category/blogroll/my-little-pleasures/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://ejs.seniejitrakai.net</link>
	<description>a snaphot of time</description>
	<lastBuildDate>Mon, 09 Jan 2012 22:10:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>OpenOffice.org, x64 and .NET interface</title>
		<link>http://ejs.seniejitrakai.net/2011/01/23/openoffice-org-x64-and-net-interface/</link>
		<comments>http://ejs.seniejitrakai.net/2011/01/23/openoffice-org-x64-and-net-interface/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 17:28:42 +0000</pubDate>
		<dc:creator>ejs</dc:creator>
				<category><![CDATA[MatLAB]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[LibreOffice]]></category>
		<category><![CDATA[OpenOffice]]></category>

		<guid isPermaLink="false">http://ejs.seniejitrakai.net/?p=194</guid>
		<description><![CDATA[Here,&#8217;s the story short: I need to create a series of graph for highly scientific data sets. The data is calculated in MatLAB, but the export of figures in MatLAB is a pain for me. On the other hand OpenOffice.org seems to be the right tool for the job. The latest MatLAB has the function, [...]]]></description>
			<content:encoded><![CDATA[<p>Here,&#8217;s the story short:</p>
<p>I need to create a series of graph for highly scientific data sets. The data is calculated in MatLAB, but the export of figures in MatLAB is a pain for me.</p>
<p>On the other hand OpenOffice.org seems to be the right tool for the job. The latest MatLAB has the function, called &#8216;xlswrite&#8217;. Happy with the fact, hoping it should write the XLS file I fire it up and&#8230;</p>
<p>Ouch. One must have Excell installed, as the data export goes through the ActiveX. If no Excell is found, the data is exported into CSV file, overwriting the file every time. Not the Right Thing.<span id="more-194"></span></p>
<p>The job was done via ordinary &#8216;csvwrite&#8217;, but adding data, importing the file to OpenOffice.org Calc and producing a series of graph.</p>
<p>And the milestone is creating &#8216;odswrite&#8217;, implementing the same functionality as &#8216;xlswrite&#8217; presents. As MatLAB supports .NET and OpenOffice.org can be controlled via .NET-UNO bridge, .NET implementation of the function seems to be the easiest task.</p>
<p>The first problem found is it&#8217;s impossible to load &#8216;cli_cpputype&#8217; NET assembly on x64 systems. I&#8217;m not sure if it is because &#8216;cli_cpputype&#8217; is compiled for .NET 2.0, but the problem is too seriuos.</p>
<p>A <a href="http://ejs.seniejitrakai.net/njufsams/OpenOfficeTestApp.exe">small .NET program</a>, based on<a href="http://www.suite101.com/content/creating-an-openoffice-writer-document-with-c-a123686">Creating an OpenOffice Writer Document with C#</a> and<a href="http://www.suite101.com/content/creating-an-openoffice-calc-document-with-c-a124112"> Creating an OpenOffice Calc Document with C# </a>was created. In the case of success, it writes 2 files to user&#8217;s desktop:  &#8220;OpenOfficeTestFile.odt&#8221; for Writer and &#8220;OpenOfficeTestFile.ods&#8221; for Calc.</p>
<p>Here&#8217;s the source for C#. Sorry fot the mess, it&#8217;s my first .NET and C# programm ever compiled <img src='http://ejs.seniejitrakai.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<pre>using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

// OOorg assemblies
using unoidl.com.sun.star.lang; 
using unoidl.com.sun.star.uno; 
using unoidl.com.sun.star.bridge; 
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.text;
using unoidl.com.sun.star.beans;
using unoidl.com.sun.star.sheet;
using unoidl.com.sun.star.container;
using unoidl.com.sun.star.table;

namespace OONETTest
{
 class OpenOfficeTestApp 
 {
 //Define a file name. Change this to an existing path! 
private static string FileName      = @"OpenOfficeTestFile";  

 static void Main(string[] args)
 {
 string fDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
 string fFileName = fDesktop + "\\" + FileName;

//Call the bootstrap method to get a new ComponentContext 
 //object. If OpenOffice isn't already started this will 
 //start it and then return the ComponentContext.  

 unoidl.com.sun.star.uno.XComponentContext localContext =  uno.util.Bootstrap.bootstrap(); 

 //Get a new service manager of the MultiServiceFactory type 
 //we need this to get a desktop object and create new CLI 
 //objects.  

 unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory =  (unoidl.com.sun.star.lang.XMultiServiceFactory) localContext.getServiceManager(); 

 //Create a new Desktop instance using our service manager 
 //Notice: We cast our desktop object to XComponent loader 
 //so that we could load or create new documents.  

 XComponentLoader componentLoader = (XComponentLoader) multiServiceFactory.createInstance("com.sun.star.frame.Desktop" ); 

 //Create a new blank writer document using our component 
 //loader object. 
 XComponent oDoc = componentLoader.loadComponentFromURL( "private:factory/swriter",  //a blank writer document 
 "_blank", 0,       //into a blank frame use no searchflag 
 //use no additional arguments. 
 new unoidl.com.sun.star.beans.PropertyValue[0] 
 ); 

 //Cast our component to a the XText interface 
//and write some simple text into document.  

 ((unoidl.com.sun.star.text.XTextDocument)oDoc).getText().setString("Testing OpenOffice.org .NET interface"); 

 //After we insert our text, we cast our component to XStorable 
 //to save it onto the harddisk  

 ((XStorable)oDoc).storeToURL( //Convert the file path into a OpenOffice path 
 PathConverter(fFileName + ".odt"),
 new unoidl.com.sun.star.beans.PropertyValue[0]);            //no additional arguments  

 // close the Writer
 oDoc.dispose();

 // according to
 //http://www.suite101.com/content/creating-an-openoffice-calc-document-with-c-a124112

 //Create a new blank writer document using our component 
 //loader object. 
 XComponent oCalc = componentLoader.loadComponentFromURL("private:factory/scalc",  //a blank Calc document 
 "_blank", 0,       //into a blank frame use no searchflag 
 //use no additional arguments. 
 new unoidl.com.sun.star.beans.PropertyValue[0]
 );

 // get sheets
 XSpreadsheets oSheets = ((XSpreadsheetDocument)oCalc).getSheets();
 XIndexAccess oSheetsIA = (XIndexAccess) oSheets;
 // access sheet by index
 XSpreadsheet oSheet = (XSpreadsheet) oSheetsIA.getByIndex(0).Value;</pre>
<pre>//write some data:
//Each cell in a Calc sheet is indexed by its column and row, so that text (for example) is written to cell A1 by using:

 XCell oCell = oSheet.getCellByPosition( 0, 0 ); //A1
 ((XText)oCell).setString("Testing OpenOffice.org .NET interface");</pre>
<pre>oCell = oSheet.getCellByPosition( 0, 1 ); //A2
 ((XText)oCell).setString("Cost");

 //And a number can be written to B1 by using:
 oCell = oSheet.getCellByPosition( 1, 1 ); //B2
 oCell.setValue(200);

 //And the "setFormula" methods is, of course, used to enter formulae (in this example into B3):

 oCell = oSheet.getCellByPosition( 1, 2 ); //B3
 oCell.setFormula("=B2 * 1.175");

 //After we insert our text, we cast our component to XStorable 
 //to save it onto the harddisk  

 ((XStorable)oCalc).storeToURL( //Convert the file path into a OpenOffice path 
 PathConverter(fFileName + ".ods"),
 new unoidl.com.sun.star.beans.PropertyValue[0]);            //no additional arguments  

 // close Calc
 oCalc.dispose();

 MessageBox.Show("OpenOffice document '" + fFileName + ".odt' saved, \n" + "OpenOffice document '" + fFileName + ".ods' saved", "OpenOffice .NET Test App");

 } 

 /// 
 /// Convert file path  into OO file format 
 /// 
 ///

 private static string PathConverter( string file) 
 {
 try 
 {
 file = file.Replace(@"\", "/");
 return "file:///"+file; 
 }
 catch (System.Exception ex) 
 {
 throw ex; 
 }
 }
 }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://ejs.seniejitrakai.net/2011/01/23/openoffice-org-x64-and-net-interface/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Migration hell: moving printers in Windows</title>
		<link>http://ejs.seniejitrakai.net/2010/10/20/migration-hell-moving-printers/</link>
		<comments>http://ejs.seniejitrakai.net/2010/10/20/migration-hell-moving-printers/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 00:28:26 +0000</pubDate>
		<dc:creator>ejs</dc:creator>
				<category><![CDATA[My job]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://ejs.seniejitrakai.net/?p=164</guid>
		<description><![CDATA[Our campus, Faculty of Architecture, VGTU is moving to the totally new subnet. As we use DHCP for IP distribution, no real problems except `sed` are going to appear. The pleasing moment is we are getting a fresh IP range. The headache is TCP/IP printers. WPKG has good printer addition/ installation guide in http://wpkg.org/Printer_configuration , [...]]]></description>
			<content:encoded><![CDATA[<p>Our campus, <a href="http://www.ar.vgtu.lt">Faculty of Architecture</a>, <a href="http://www.vgtu.lt">VGTU</a> is moving to the totally new subnet. As we use DHCP for IP distribution, no real problems except `sed` are going to appear.<br />
The pleasing moment is we are getting a fresh IP range.<br />
The headache is TCP/IP printers.</p>
<p>WPKG has good printer addition/ installation guide in http://wpkg.org/Printer_configuration , but it does not cover changing IP port numbers.<br />
As a CEO on all computer infrastructure, I need to find any solution to make the movement smoothly.</p>
<p>I was unable to find a ready-made solution, and in-house tool appeared after several hours in the Net.<br />
I need to apologize for bugs and errors, as it is the first (and hopefully the last) VB script. It uses WMI. Testing box was W7, x64.<br />
Maybe someone will find it useful.</p>
<p>Call the file <strong>chprinterport.vbs</strong><span id="more-164"></span><br />
<code><br />
Set args = WScript.Arguments<br />
if args.Count < 2 then<br />
	Wscript.Echo " "<br />
	Wscript.Echo " Change IP ports for TCP/IP printers on Windows boxes"<br />
	Wscript.Echo " "<br />
	Wscript.Echo "   Usage: <em>cscript chprinterport.vbs old_TCP/IP_port new_TC/IP_port</em>"<br />
	Wscript.Echo " "<br />
	Wscript.Echo "    eg: cscript chprinterport.vbs 192.168.1.2 192.168.2.3 will change"<br />
	Wscript.Echo "      port IP from 192.168.1.2 to 192.168.2.3"<br />
	Wscript.Echo " "<br />
	Wscript.Echo "    Partial match is possible, so:"<br />
	Wscript.Echo "      cscript chprinterport.vbs 192.168 210.23 will change"<br />
	Wscript.Echo "      port IP from 192.168.x.y to 210.23.x.y"<br />
	Wscript.Echo " "<br />
	Wscript.Echo " Inspired by:"<br />
	Wscript.Echo "   http://wpkg.org/Printer_configuration"<br />
	Wscript.Echo "   http://gallery.technet.microsoft.com/ScriptCenter/en-us/5777dc6a-9783-43d7-ac8e-fd3bd739690c"<br />
	Wscript.Echo "   http://www.pcreview.co.uk/forums/showpost.php?s=8a077fc479806d3fc03bf734d57b357f&#038;p=5622799&#038;postcount=6"<br />
	Wscript.Echo " "<br />
	Wscript.Echo "                                                            License - BSD"<br />
	Wscript.Echo " "<br />
	Wscript.Echo "                           (c) 2010 ejs@seniejitrakai.net, ejs@ar.vgtu.lt"<br />
	Wscript.Echo "                                             http://ejs.seniejitrakai.net"<br />
  else<br />
	oldIPAddress    = args.Item(0)<br />
	newIPAdress = args.Item(1)<br />
        Dim strComputer<br />
        Dim Result<br />
        strComputer = "."<br />
        Result = ""<br />
	Set objWMIService = GetObject("winmgmts:" &#038; _<br />
"{impersonationLevel=impersonate,(LoadDriver)}!\\" &#038; strComputer &#038; _<br />
"\root\cimv2")<br />
	Set colPorts = objWMIService.ExecQuery ("Select * from Win32_TCPIPPrinterPort")<br />
	For Each objPort in colPorts<br />
		wscript.echo "Found TCP/IP printer port: " &#038; objPort.HostAddress  &#038; ", named " &#038; objPort.Name<br />
	if UCase(Mid(objPort.HostAddress, 1, Len(oldIPAddress))) = oldIPAddress Then<br />
		objPort.HostAddress = newIPAdress &#038;  Mid(objPort.HostAddress, Len(oldIPAddress)+1)<br />
		Wscript.Echo "New Printer port: " &#038; objPort.HostAddress<br />
		Result =  objPort.Put_<br />
	    If Len(Result) > 0 Then<br />
			WScript.Echo "Updated TCP/IP printer port: " &#038; objPort.HostAddress &#038; ", named " &#038; objPort.Name<br />
		Else<br />
			WScript.Echo "Error " &#038; Result &#038; " updating TCP/IP printer port: " &#038; objPort.HostAddress<br />
			WScript.Quit<br />
		End If<br />
	 end if<br />
	 Next<br />
end if<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://ejs.seniejitrakai.net/2010/10/20/migration-hell-moving-printers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekend project &#8211; USBasp</title>
		<link>http://ejs.seniejitrakai.net/2008/09/21/weekend-project-usbasp/</link>
		<comments>http://ejs.seniejitrakai.net/2008/09/21/weekend-project-usbasp/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 18:26:50 +0000</pubDate>
		<dc:creator>ejs</dc:creator>
				<category><![CDATA[Hobbies]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Atmel]]></category>
		<category><![CDATA[ISP]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://ejs.seniejitrakai.net/?p=89</guid>
		<description><![CDATA[I had some ideas to go out before, but as i got terrible cold last Friday, I had to postpone all of them. I feel a bit better today, so decided to build USBasp &#8211; an USB port ISP programmer for Atmel product family. I used STK 200/300 dongle before, but it works from parallel [...]]]></description>
			<content:encoded><![CDATA[<p>I had some ideas to go out before, but as i got terrible cold last Friday, I had to postpone all of them.</p>
<p>I feel a bit better today, so decided to build USBasp &#8211; an USB port ISP programmer for Atmel product family. I used STK 200/300 dongle before, but it works from parallel port only.<br />
<a href='http://ejs.seniejitrakai.net/USBasp/USBasp_stage1.jpg'><img class="right" src="http://ejs.seniejitrakai.net/USBasp/usbasp_stage1-300x105.jpg" alt="USBasp: fresh PCB" title="usbasp_stage1" width="300" height="105"/></a><br />
Lets start: the schematics is from <a href="http://www.fischl.de/usbasp/"> http://www.fischl.de/usbasp/ </a>. You can find some schematics and pre-routed PCB&#8217;s there. </p>
<p>What I need is USB B type or MiniUSB connector, SMD parts, small footprint, single &#8211; sided PCB. The one I liked is by Thomas Pfeifer, <a href="http://thomaspfeifer.net/atmel_usb_programmer.htm"> http://thomaspfeifer.net/atmel_usb_programmer.htm</a>. The problem is I found no files for Eagle there and had to re-create the PCB. </p>
<p>Additional features are:</p>
<ul>
<li>RC filters on MOSI, MISO and SCK lines to suppress ringing, as suggested in <a href="http://www.avrfreaks.net/index.php?name=PNphpBB2&#038;file=viewtopic&#038;t=33265">AVR Freaks forum</a>;</li>
<li>Signal from oscillator (XTAL1) is routed to the pin 3 on IDC connector via jumper &#8211; a handy feature to debrick the MCU if you accidentally fused external oscillator;</li>
<li>Inductor on the power line.</li>
</ul>
<p>The PDF files with the layout are <a href="http://ejs.seniejitrakai.net/USBasp/USBasp_single_sided_board.pdf">here</a>, an A6 &#8211; size mirrored image for direct printing on OHP is <a href="http://ejs.seniejitrakai.net/USBasp/USBasp_bottom_mirrored_multi.pdf">here</a>. </p>
<p>Added on 2008-10-01:<br />
<a href='http://ejs.seniejitrakai.net/USBasp/usbasp-top-populated_.jpg'><img src="http://ejs.seniejitrakai.net/USBasp/usbasp-top-populated_-300x122.jpg" alt="USBasp top side, populated" title="USBasp top side, populated" width="300" height="122" class="right" /></a><br />
<a href='http://ejs.seniejitrakai.net/USBasp/usbasp-bottom-populated.jpg'><img src="http://ejs.seniejitrakai.net/USBasp/usbasp-bottom-populated-300x114.jpg" alt="USBasp bottom side, populated" title="USBasp bottom side, populated" width="300" height="114" class="right" /></a><br />
First, it works. Both connected directly or via USB hub.<br />
Second: don&#8217;t create anything while you are ill. Actually, pin number 5 on miniUSB connector MUST be grounded, while pin number 4 can be grounded or left floating. I&#8217;ve used i jumper wire to solve the issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejs.seniejitrakai.net/2008/09/21/weekend-project-usbasp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Colorization</title>
		<link>http://ejs.seniejitrakai.net/2005/10/19/colorization/</link>
		<comments>http://ejs.seniejitrakai.net/2005/10/19/colorization/#comments</comments>
		<pubDate>Wed, 19 Oct 2005 18:57:50 +0000</pubDate>
		<dc:creator>ejs</dc:creator>
				<category><![CDATA[MatLAB]]></category>

		<guid isPermaLink="false">http://ejs.seniejitrakai.net/?p=10</guid>
		<description><![CDATA[505510 Quite interesting article on image processing. The MatLAB source, presented on the site, need some minor enhancments. Authors may contact me, if they want . Attention: the program is really slow. I used &#8216;direct solver&#8217;, and it took almost 10 minutes to proceed the image.]]></description>
			<content:encoded><![CDATA[<div class="g2image_float_right"><wpg2id>505</wpg2id><wpg2id>510</wpg2id></div>
<p>Quite interesting <a href="http://www.cs.huji.ac.il/~yweiss/Colorization/">article</a> on image processing. The MatLAB source, presented on the site, need some minor enhancments. Authors may contact me, if they want <img src='http://ejs.seniejitrakai.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .<br />
<strong>Attention:</strong> the program is really slow. I used &#8216;direct solver&#8217;, and it took almost 10 minutes to proceed the image.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejs.seniejitrakai.net/2005/10/19/colorization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JPEG-2000 in MatLAB</title>
		<link>http://ejs.seniejitrakai.net/2005/04/16/jpeg-2000-in-matlab/</link>
		<comments>http://ejs.seniejitrakai.net/2005/04/16/jpeg-2000-in-matlab/#comments</comments>
		<pubDate>Fri, 15 Apr 2005 22:07:45 +0000</pubDate>
		<dc:creator>ejs</dc:creator>
				<category><![CDATA[Hobbies]]></category>
		<category><![CDATA[MatLAB]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ejs.seniejitrakai.net/?p=4</guid>
		<description><![CDATA[Any idea how to produce and read the <a href="http://www.jpeg.org/jpeg2000/">JP2</a> file in MatLAB?]]></description>
			<content:encoded><![CDATA[<p>Any idea how to produce and read the <a href="http://www.jpeg.org/jpeg2000/">JP2</a> file in MatLAB?<br />
The easiest way should be writing middleware in Java to specific library. The things are complicated, as i need to get and modify data from every stage of encoding/decoding, like color space transformations, quantization, EBCOT (including bit-plane decomposition, bit-plane processing, encoding) and rate-encoders.<span id="more-4"></span></p>
<ul>
<li>There is <a href="http://www.ece.uvic.ca/~mdadams/jasper/">JasPer</a>, written in C. Not all functions of Jpeg-2000 basic specification is implemented now;</li>
<li><a href="http://jj2000.epfl.ch/">Jj2000</a>, written in Java; only basic functionality is provided;</li>
<li><a href="http://www.kakadusoftware.com/welcome.html">Kakadu</a>, written in C++ and has JNI bindings. Almost perfect inplementation of the Jpeg2000 image compression standart; data-on-demand, progressive transmision, even video encoding/decoding is supported.</li>
</ul>
<p>As i tried to reproduce kdu_encoder in Java, no image is appearing in the output file, while original C++ file works well.</p>
<p>Need more timeto research.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejs.seniejitrakai.net/2005/04/16/jpeg-2000-in-matlab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

