xyzio

Archive for the ‘Programming’ Category

Free Online Wordsearch Puzzle Generator

leave a comment »

A Wordsearch puzzle is a puzzle that contains words hidden in a grid of text. It is a fun activity used to teach children spelling and to help memorize information like country capitals.

Interested in creating your own Wordsearch puzzle? Then try out the Free Online Wordsearch Puzzle Generator at http://xyzio.com/Projects/WordSearch/Default.aspx.

This Word Search generator was written in C#/ASP.NET and generates PDFs using the iTextSharp library.

Sample Page:

Free Online Wordsearch Example

Wordsearch Example

Advertisements

Written by M Kapoor

June 29, 2013 at 12:23 am

ArduiNIX review

with one comment

Overview:

According to the ArduiNIX website, the “ArduiNIX shield is a user programmable platform for driving multiplexed Nixie tube or other high voltage displays.”  I bought the ArduiNIX shield after I read about Nixie tubes and wanted to try them out.  Nixie tubes are old-school tube based character displays that require voltages in the range of 150-200V to run.  The ArduiNIX board has an on-board SMPS power supply that generates these voltages and it has the correct interface to drive Nixie tubes from a Arduino board.  However, in my case I’m using a Netduino board to do the driving.ArduiNIX

The ArduiNIX is open source – the CAD layout files for the board and parts list are available on the site.  In addition, there is a forum where users can ask questions and discuss issues.

Pricing:

Once you consider the cost of acquiring all the parts and putting them together, the prices in their store are reasonable.  You can buy a complete kit for $45 including shipping.  The kit doesn’t include the NIXIE tubes.  This seems reasonable because a user may want to use a different type of tube than the one they supply.  You can get a fully assembled board for $94.  Based on the ease of assembly, I think that purchasing a fully assembled board is not worth the price.

Assembly:

Assembling the board took me about 2 hours and is straightforward.  They have a excellent step-by-step tutorial on their site.  All the parts are through-hole and are marked clearly on the PCB.  Since there are many different value resistors, double check the resistances and be careful when soldering them into the board because it is easy to get them confused.

Usage:

Using the board is straightforward.  You write your code, plug it into your Arduino or Netduino, and apply power.

Design:

Looking at the layout of the  ArduiNIX I see some definite areas for improvement.  Based on the Nixie supply design and analysis posted on Nick Smith’s website, the ground plane is run under the switching supply inductor which causes energy loss.  In addition, the ArduiNIX design uses very small traces.  This does not provide the necessary low impedance paths between components.  Despite these drawbacks, the ArduiNIX works well and is able to adequately power the IN-17 nixie tubes for which it was designed.

Written by M Kapoor

March 12, 2011 at 5:23 pm

Generating PDFs using iTextSharp on Mono

leave a comment »

I was looking for a .NET pdf generator so that I could add online bingocard generation to my side project, BingoWords.  The code and website are built using .NET and I run the site under Mono on a VPS at Linode.  So, it was important that the PDF generator run under Mono without issues.  Being cheap and full featured were two other desired features.  After some research, I found that there were two major players that satisfied this criteria,  PDFSharp and  iTextSharp.  Both are open source, free, and are fully featured.

Although some posts on the web indicated that PDFSharp would run under Mono, it was a no-go from  the beginning.  It failed the mono compatibility tool – Mono Migration Analyzer or M0MA almost right away.  I still decided to try out PDFSharp with Mono after reading a few posts stating that it may work if my code avoided the non-Mono compatible portions of the code but that was a total failure.  

So, I had no choice but to use iTextSharp.  iTextSharp passed under MoMA and it worked great on my Linode VPS under Mono.  With iTextSharp, I can generate PDFs that comply with the PDF standard and are viewable on every major platform.  So, if you are planning to generate PDFs under Mono, I would highly recommend iTextSharp.  Or to get a better sense of the features, try out my free Online Bingo Card Generator!

 I noticed that weren’t many code samples available while doing my research and coding the Bingo Card Generator.  So, here are some samples from my code for those that are just getting started:

Creating a new PDF document:

MemoryStream ms = new MemoryStream();
Document document = new Document(PageSize.LETTER);
PdfWriter writer = PdfWriter.GetInstance(document, ms);
document.Open();

Creating a BaseFont.  A BaseFont contains the parameters of the font that is written to the PDF document:

BaseFont bf = BaseFont.CreateFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

Writing center-aligned text to 400pts from the left and 400pts from the top:

cb.BeginText();
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, “Title Text”, (int)(Math.Abs(400, 400, 0);
cb.EndText();

Getting the width of a string in points:

titleWidth = (int)cb.GetEffectiveStringWidth(“Hello World!”, false);
Setting the font size of a BaseFont:
cb.SetFontAndSize(bf, titleFontSize);

Draw a line from the top left to the bottom left of the document:

cb.MoveTo(document.Left, document.Top);
cb.LineTo(document.Left, document.Bottom);
cb.Stroke();

Editing the document’s properties:

document.AddTitle(“Designed by BingoWords.com”);
document.AddAuthor(“Author goes here!”);
document.AddSubject(“Subject Goes Here!”);
document.AddKeywords(“Keyword1, keyword2, …”);

Closing your document:

document.Close();

Put this after the “document.Close()” to return your document with the name “file.pdf” when a user clicks on a link:

Response.ContentType = “application/pdf”;
Response.AddHeader(“content-disposition”, “attachment;filename=file.pdf”);
Response.Buffer = true;
Response.Clear();
Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
Response.OutputStream.Flush();
Response.End();

I hope this comes in handy.  Feel free to contact me if you have any questions or comments.

Written by M Kapoor

June 20, 2010 at 5:52 am

Use Apache’s mod_proxy to Set Up a Proxy Server

leave a comment »

A proxy server is a server that sits between your computer and the internet and services your requests to the internet. Many companies use proxy servers to filter employee internet requests since a proxy server can also modify or block your request.

My goal in setting up a proxy server was to give myself a means of encrypting my web traffic when I am in insecure locations such as airports and restaurants.

Setup
To set up a proxy server, you first need a server. You can use a machine on your home network, get a dedicated server, or get a virtual server. I chose to get a virtual server through slicehost.com. I am using their base $20 256 slice with Ubuntu 8.04 LTS. In addition to proxy services I also use it as a virtual desktop and, since I can leave it on all the time, run long term jobs.

I set up the proxy server to only allow connections from the local host. I can then connect to the local machine via SSH and surf the web through the SSH tunnel. This way, the connection to my server is encrypted and no one can use the proxy server unless they have an account on my machine.

The setup is simple but I had to go to several sources to figure it all out, hence this article.

First, install Apache:

apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

Next, link to the mod_proxy modules:

cd /etc/apache2/mods-enabled
ln -s /etc/apache2/mods-available/proxy_http.load
ln -s /etc/apache2/mods-available/proxy_ftp.load
ln -s /etc/apache2/mods-available/proxy_connect.load
ln -s /etc/apache2/mods-available/proxy.load

Then, in your httpd.conf file located at /etc/apache2 make
entries to configure the server:


ProxyRequests On
ProxyVia Block
<Proxy *>

   Order deny,allow
   Deny from all
   Allow from 127.0.0.1
</Proxy>

Here, ProxyRequests configures Apache as a forward proxy. <Proxy *> and </Proxy> delineate the proxy configuration block. The block tells Apache to deny all connections except from the local machine (127.0.0.1).

Now, restart Apache:

apache2ctl graceful

Finally, in your browser configure your host to use the proxy server you just set
up:

Sources:
slicehost.com: Ubuntu Hardy Apache and PHP install guide
serverwatch.com: Configuring Apache 2.0 as a Forward Proxy Server

Written by M Kapoor

November 1, 2009 at 11:40 pm

Komodo 5.0 Review

leave a comment »

I’ve been using Komodo ever since version 3.5 came out several years ago. I first found out about it while looking for a Windows Perl distribution and happened upon the Activestate website. So, what is Komodo? Komodo is a IDE geared towards dynamic languages like Python/Perl/Tcl/Ruby that runs on all 3 major OS platforms (Windows, Linux, and OSX). It is put out by Activestate, the same company that puts out the most widely used Windows Perl distribution –Main Window showing debugger and variable viewers Activestate Perl.  I bought Komodo because I liked the built in Perl debugger and syntax highlighting. I purchased the upgrade to version 4.0 because it added VI keybindings. Version 5.0 didn’t have any features I thought were compelling, but I purchased the upgrade anyway because I wanted to support Activestate.

Features:
Komodo is a feature rich editor. Besides the required syntax highlighting, it has editing of remote files over FTP and SFTP, version control integration, VI emulation mode, a very nifty graphical debugger, http request and response inspector and editor (HTTP inspector), source control integration, a regex constructor (RX toolkit), and an interactive shell that lets you try out commands on the fly. These are just the features I use on a regular basis! Komodo is also extensible via scripts, supports macros, customizable keyboard shortcuts, and much more.

Usability:
Komodo is very user friendly.  Besides the VI keybindings, you can also customize the menu by assigning your own key combinations to the commands you use the most.  The interface stays out of your way until you need it, the main typing window takes up most of the screen with the quick link buttons  listed along the top.  You can bring up the debugger or your source control windows at the bottom and there are side tabs to let you quickly access files in your project, variables, and functions.  One area that is lacking is the help – it is sparse in some areas, especially on how to access the API and so sometimes I have to resort to trial and error.

The syntax highlighting is great, it makes the code readable and there are little red squiggles show you where you have errors in your code.  A little drop down pops up when you access member variables, however it is not as comprehensive as Microsoft’s intellisense in that it doesn’t perform the drop-down for every variable.

A great feature I use regularly but is not found in most IDEs is the ability to edit remote files over FTP and SFTP.  This allows me to get syntax highlighting, code folding, code completion and all the other nifty features of the IDE on files that can only be accessed via SSH or telnet.  This is great because a lot of my work is done on UNIX machines that don’t come with fancy editors but allow access via SSH and telnet.

Komodo Regular Expression Editor

Komodo Regular Expression Editor

I mainly use Komodo for Perl and C/C++ development but I have dabbled with Ruby on Rails using Komodo and it also shines in this area.  It has shortcuts to automatically generate scaffolding items and you can watch your site execute using the built in debugger.

I’ve discussed the features I use the most and like the best but Komodo has many more features that will interest others who work with different languages or with different needs.  Check out their features page for a full list of everything Komodo can do.  Activestate also offers a trial version and has a lite version of their IDE in Komodo Edit.

Conclusion:
Overall, Komodo is great software and I would highly recommend it to anyone who works with dynamic languages.  I don’t regret buying it since it has paid me back many times in saving me time and reducing the frustration of debugging code.

Pros:

  • Versatile and feature rich
  • Easy to modify to suit your tastes
  • Advanced debugging support
  • Great code editing features
  • Works on all major platforms – Windows, Mac, Linux

Cons:

  • Expensive!
  • Only supports dynamic languages

Checking out Slashdot with HTTP Inspector

Written by M Kapoor

June 12, 2009 at 3:09 am

Mapping foreign keys to primary keys in an Objectdatasource

leave a comment »

I was having a tough time finding how to display database data from a primary key in a drop-down and then have the selected item show up in my business class object when it returned.

I wanted to do this using an Objectdatasource because I had to reference several different tables in order to display my data.  As a newbie, I spent several days struggling on it when I found this set of tutorials on Microsoft’s MSDN site, specifically tutorial 20.  These tutorials nicely cover the basics of data manipulation in ASP.NET using C# and the Objectdatasource.

I hope this helps other like me who are struggling with the same problem.

Written by M Kapoor

January 26, 2009 at 2:49 am

Posted in ASP.NET, Programming, Resource

Tagged with ,