Howto


Development and EPICS and Howto22 Oct 2007 08:07 pm

So I have been doing some more Gnary Queries for MyEPICS.

We have a table called TeamChoice that has 3 columns, userid, teamid, and choice. These represent a person’s 5 choices that they make when registering for EPICS. There is one special row for each person. If the person is not assigned to a team, they are given a choice=0 with their current team choice. So with 5 team choices, each user has 6 rows in the database.

The Scenario

What I wanted to do is find all the students who are currently in their first team’s bucket. So that means that for each user, I wanted to get the teamid where choice=0, and compare it to where choice=1. If they are the same teamid, I wanted to return the result. This probably could be accomplished by some script, but a database should be able to give me the results w/o any scripting.

The Method

The way to accomplish this is through subqueries. I realized that I am essentially querying against two tables, then doing a join on the userid. The first table all the records for students and their first choice, the second table is the records for students and their current choice. If I then join the two tables together on their userid, then I will have what their first choice is, and their current choice. All I need to do next is add a where clause that makes sure that I only get records with the two results are the same and it’s over.

The Query

SELECT User.username
FROM (
SELECT TeamChoice. *
FROM User
INNER JOIN TeamChoice ON User.id = TeamChoice.userid
WHERE TeamChoice.choice =1
) AS firstchoice
INNER JOIN (
SELECT TeamChoice. *
FROM User
INNER JOIN TeamChoice ON User.id = TeamChoice.userid
WHERE TeamChoice.choice =0
) AS currentchoice
ON currentchoice.userid = firstchoice.userid
INNER JOIN User ON User.id = currentchoice.userid
WHERE firstchoice.teamid = currentchoice.teamid
Development and Howto and School17 Oct 2007 01:40 pm

Today I finished up some of the coding for the my Rubix Cube project using Direct X and LINQ. Luke Hoersten and Nate Hobbs were my partners in developing the program. All of us worked on coming up with designing a sufficient data structure. I worked on implementing the data structure and the user interface / Direct X stuff. Luke focused on refactoring the code, and coming up with parts of the solving algorithm. Nate worked on parts of the solving algorithm.

Previous Posts

I have outlined some problems we had while developing the application and also some design decisions that were made to include LINQ. The way our program solves it is that it goes about it the way that a human would.

Solving the cube

The program starts with trying to solve the bottom layer, then solve the middle layer, then finally the top layer. Luke would be able to give a much better explanation of how it worked. It was suggested by our professor that we create a tree by attempting every move, then for every move try every move, etc… This we thought would not be a great way to solve it for two reasons. The first being that there are 18 possible moves to make on a cube, and if you want to try and go n levels deep, it would have to compute 18n states. Not only that, but it would have to store every state, score them, then take the path with the best score. To go 6 levels deep, you need to compute 34 million different states, for 7 levels deep, you need to compute 612 million states. Computers are good, but they aren’t that good.

This would not be completely terrible, if you had a smart heuristic for scoring. If every time you computed every one of those states, you were guaranteed to get closer to the solution, then you would only be spending time solving it, and time a computer has. The heuristic that was presented was to find proximity of where a block is to where it should be. This is not the greatest either because what happens when you are almost finished solving it, and you have only one or two cubes out of place (or oriented wrong). You have to end up messing up your cube really bad in order to solve it, and if you’re algorithm doesn’t go deep enough, you won’t find your solution because your current state will always be better than where you are going.

The Program

Basically, here is the outline of the program:

Block.cs – A tiny block within the rubix cube. The rubix cube contains 27 of these blocks.
Cube.cs – The cube structure, contains helper functions to orient and move sides of the cube.
Solver.cs – The class that solves the rubix cube.
UI.cs – Handles the DirectX and drawing of the rubix cube.

We haven’t formally licensed the program, but I’m sure Luke and Nate wouldn’t mind if we say it’s GPL’d. Basically give us credit for whatever you do with it and don’t sell it.

URL: Rubix Cube in C# using LINQ
Alternatively, you can also check out the Mercurial sources at: Luke’s Mercurial Sources

Development and Howto13 Aug 2007 08:50 am

I have just read about a new feature in Microsoft .Net 3.5 named LINQ. Microsoft describes this as

General-purpose query facilities added to the .NET Framework apply to all sources of information, not just relational or XML data. This facility is called .NET Language-Integrated Query (LINQ).

That, in my opinion, is a rather vague description of what this does. A query facility? Reading more, I see

We use the term language-integrated query to indicate that query is an integrated feature of the developer’s primary programming languages (for example, Visual C#, Visual Basic). Language-integrated query allows query expressions to benefit from the rich metadata, compile-time syntax checking, static typing and IntelliSense that was previously available only to imperative code. Language-integrated query also allows a single general purpose declarative query facility to be applied to all in-memory information, not just information from external sources.

This still doesn’t quite explain what this query facility with syntax checking and IntelliSense does. When I continued reading the page, I finally came across an example. Imagine the following C# code:

Using System;
using System.Linq;
using System.Collections.Generic;
class app {
static void Main() {
string[] names = { "Burke", "Connor", "Frank",
"Everett", "Albert", "George",
"Harris", "David" };
}
}

Now, imagine you wanted to get all the names that were 5 characters long, and print them in all upper case. What you would probably do is similar to the following: (PSEUDO CODE)

string upperNames[]
//get all names that are length 5 and push them onto the upperNames
for (int x=0;x if (names[x].length() == 5) {
upperNames.push(names[x].ToUpper());
Console.WriteLine(upperNames.peek());
}
}

Here is how you would accomplish the following with LINQ:

IEnumerable query = from s in names
where s.Length == 5
orderby s
select s.ToUpper();

Wow, that's some pretty cool stuff. There is some more stuff that is outlined in the article, but at a first glance, it's pretty neat.

Development and Howto and Whirlpool02 Aug 2007 03:37 pm

Please note, these are all my own personal views and are not in any way representative of the company I work for.

At Whirlpool, I have been working with two form building utilities for SAP. I was looking at these solutions for creating an offline expense reporting tool for SAP’s Travel Management module. One of them is Adobe Interactive Forms and the other is Microsoft Infopath. Both of these are extremely powerful tools that allow you to quickly create forms. What’s even better, is that given a web service, both of them can create a form that molds to it in a matter of a few clicks.

The Scenario

A tool is needed to be developed to allow for an employee to create an expense report while traveling on the plane. Like e-mail, this tool should be able to synchronize all data when it is first launched. When offline, the traveler should be able to fill out the expense report as if at the office, connected to the network. When the traveler comes back online, the report would synchronize again and submit the data that has been changed. We believed that the best solution for our scenario was to create web services that would allow us to accomplish all of the synchronizing calls to the back end system.

Adobe Interactive Forms

Adobe Interactive Forms seemed to be the most widely used method by companies that use SAP. When looking online and through documentation, creating them to use web services didn’t seem to be used at all. I investigated and poked and prodded until I was able to find that you can access Adobe LIveCycle Designer directly from: “C:\Program Files\Adobe\Designer 7.1\FormDesigner.exe” without having to go through SAP NetWeaver. From here I was able to bind it to a WSDL file, but for some reason it would never submit the data, or receive anything back. Clicking a button did nothing. It was like an HTML input button w/o a form surrounding it. After a few attempts to get it to work, I noticed that if I click on the button, go over to the “Execute” tab, then tell it to post to server, and not the client, then it appears to do something.
change.PNG

Then I went and tried to submit the form and this is the result that I got
error.PNG

I was never able to find a solution to this error, as descriptive as it is.

Microsoft Infopath

Using Microsoft Infopath, File->Design a form
1.PNG

You want to send and receive data from this web service
2.PNG

Then manually type in the address to your WSDL file.
3.PNG

Click next a few times until you get to this screen, and choose to send the entire XML file.
4.PNG

Now, expand all your fields and drag the queryFilter folder into the top box, and choose the relevant selection. I was using BAPI_GET_USER_DETAILS
5.PNG

Do the same with the lower field.
6.PNG

Preview the form and you should have a fancy web service running with Microsoft Infopath.

Near the time we were going to get into the thick of the tools, we had the web services take a dump on us. I was investigating how we were going to create web services for our travel expense solution when our project stopped. It was a shame as it was interesting to see how such powerful functionality can be built in a relatively short amount of time.

Development and EPICS and Howto17 Jun 2007 11:47 pm

I have been working on the MyEPICS 2.0 framework for creating a website to match roommates together. During this time, I was switching from the old layout, to a different look and feel. When the designing and implementing the MyEPICS framework, I tried to make it as modular as possible, and able to switch layouts easily.

The only big problem that I ran across was empty div tags. The author of the article does a good job of explaining exactly what happened, but doesn’t offer a solution. He may have lost 2 hours of his life finding the problem, but I lost 2 hours of my life attempting to find a solution. My solution was to add an <xsl:output> tag to my XSLT sheet, with a method of ‘html’, which then properly fixed the problem. No more were empty div tags consuming whatever was after them, and it adds a DOCTYPE declaration, which is a big bonus! Now the output passes xhtml strict.

Development and EPICS and Howto and Opinion14 May 2007 07:39 pm

I have been working with SVN for the better part of around two years, and let me say, it is wonderful! When I first started to learn about version control, I tried to learn with THE standard, CVS. Well, a new player had made its way into the hearts of many developers, and Dan turned me onto it. What was it? It was Subversion. I won’t go into many of the details that made CVS different from SVN, but let me say that it allowed me to understand version control much better than I did with CVS.

If you are familiar with what a tag and what a branch is, you can skip the next couple of paragraphs. If not, read on for my explanation of what they are.

A tag is basically a snapshot of your code at a specific point in place. You don’t make any updates to a tag, you really only use it as reference. Why would you want to do something like this? Well, mostly it is for historical reasons. Whenever you release a new version of your code, you want to tag it so that you can always check out that version w/o having to remember the version number. In SVN a tag is basically just a label for a specific version of the repository, but labeling things is important.

Branches on the other hand are a bit more involved. The standard way of explaining tags is saying that it is parallel development of your code. What exactly does this mean though? Well, you can imagine that you want to release your code at some point in the future (if not, then reread this sentence until it is a true statement). You have features X, Y and Z that are being developed and you want version 1.0 to contain these features. Well, what happens if there is feature Q that is slated to be in 2.0, but you want to start developing it now? Well, what is normally done is that you can make a branch. Usually, new development is done in the trunk, so you would branch off the 1.0 code. At this point, you will now have two developments of your code. You will have your 1.0 branch to contain X, Y, and Z, and you will have the trunk (2.0) to contain Q, X, Y, and Z. You do all development in your trunk (i.e. 2.0), and anything that you want to release into 1.0, you merge from the trunk, into the 1.0 branch.

When you begin the development of your application, tags and branches will not be necessary. Every part of development will belong in the trunk and will most likely stay there until you have some initial release of the code. From that initial release will all of this complexity start to make sense. Believe me, it took me the better part of 6 months to finally understand the whole need for tags and branches beyond the standard examples given to you from Alice and Bob.

Ok, got the idea of tags and branches? Good!

In MyEPICS, we are just now getting ready to upload the code onto SourceForge. One of the topics that came up (or I brought up) was how to mange the version numbers of the code. I want the actual version number to mean something. When developing this idea, I had borrowed quite a bit from PHP. They have X.Y.Z, where X=Major, Y=Minor and Z=Release. I would think that MyEPICS can borrow from this idea to also have a X.Y[.Z] where Z is optional. X is the major release. The decision to bump up the major release would be done through decisions of what features will be implemented. As of right now, I cannot see anything that is slated would have a major number increase (mainly because of the differences between 1.0 and 2.0, which were pretty vast).

A minor release can contain such things as the addition of one or many modules and any features that aren’t too intense of a change.

As I see it, all bug fixes that are released will go into a “Release” release. I think it would be good to call it a bug release.

As this gets more set in stone I will keep all of this updated.

Howto and PHP22 Apr 2007 06:59 pm

Background

I am wanting to become involved in PHP a bit more, and in doing so will require me to run multiple versions of PHP. The first idea that came to mind is setting up multiple installations on one of my home machines. Since I don’t want to have a full development setup on my laptop (poor little guy isn’t powerful enough), I decided to install multiple installations on my shared hosting at dreamhost.com.
Continue Reading »

Howto09 Apr 2007 12:31 am

So I have been trying to figure out something good to post as my first post on my blog, and I believe that I have found one that’s not too long, but at the same time isn’t useless.

I have recently decided to run Vista on my laptop, just to see what all the commotion was about. I will have a full review later when I feel I have had enough time with it to do a just review. What I just found was in the Task Manager, under View->Select Columns…, if you choose “Command Line”, you can see where the programs are launched from.

Continue Reading »

« Previous Page