Tuesday, March 15, 2011

GIT Merges

Learning GIT is fun!

When you want to merge and cannot do a fast forward from a remote getting CONFLICTS are inevitable. First off, if you ever mess anything up you can always

git reset --merge ORIG_HEAD

This will set you back to before the merge attempt.

When you do get a conflict, fix the file and then commit with -i like so:

git commit -i myfile.java


This will stage the file first.

Thursday, March 10, 2011

Learning PICK....

So for a new project I am starting to learn a little about PICK systems, specifically MVBase. Different way of thinking from SQL that's for sure. Anyway just some notes for myself as well as those who are looking to start...

everything is a file. you create a db with:

CREATE-FILE [DB_NAME] 3 43
In the above the 3 and 43 are modulos??? and somehow represent the size of the file as well as the file dictionaly. The command above basically creates a file as well as a file dictionary or a specification on the schema if you will. Now to create the schmea:
[ED|DE] DICT PEOPLE P-ID

in above it's either ED or DE. Then enter the command

I

This will put you in an inline insert mode. Have to refer to the MVBase docs for specifics but the following:

>001 A                                       
002 1    
003 Customer ID                                                   
004                                                                 
005                                                                        
006                                                                       
007 ML(#-####-####)          
008                                                             
009 L                                                                   
010 12

The main thing here is 002 which is the order in which this fields shows up and 003 which is the header. 007 is the formatting of the text, 009 is justification and 010 is the width allocated in the command prompt for the column.

After this is done we need to create a data file for the dictionary like so:

>ED DATA PEOPLE [id]
[id] can be anything it's just the name that you give the file. The important thing about this datafile is that it has to match the dictionary file. If in the DICT file you state on 002 that this field is item 1 then this the value in the data file NEEDS to be on the first line like so

>001 Arash

Lasty you query the file like so

>LIST PEOPLE FIRST-NAME
which should result in

>PEOPLE......First Name...
ASHARI      Arash

Next up....connecting and retriving this from Java! =)

Monday, January 10, 2011

Forcing .NET to proxy requests

Two posts back to back after being away for a couple months....I'm pumped!

So I ran into a situation where I needed to know exactly what my .NET app was doing. In particular I had to log the soap calls it was making to understand them. There are probably many ways of doing this but the way I though of was to make the server proxy it's requests through fiddler. This seems like an easy thing to do but it took me forever googling it to figure it out.

Sure enough the answer is a mere 10 lines of xml in the web.config....enjoy!

<system.net>
    <defaultProxy>
      <proxy
        usesystemdefault="False"
        bypassonlocal="True"
        proxyaddress="http://127.0.0.1:8888"/>
    </defaultProxy>
</system.net>


Put the above anywhere in the configuration section and you'll be going through port 8888.

Castle ActiveRecord and Castle Windsor Configuration for .NET

Well it's been a long time since my last post....over 2 months wow! Started a new job and it's been keeping me busy. Been working a lot with the Castle stack for .NET. It's actually a VERY nice framework based on what are now common enterprise architecture patters, or as Fowler would call them PEAA.

It actually has really good documentation that is not a freaking dissertation (hello SpringSource, I'm talking to you!).

Here is an example of how to configure the ActiveRecord Framework along with the IoC Windsor using the facilitator:

In the web.config in the config section we need to add the castle facilitator:
<configsection>
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,   Castle.Windsor">
</section>
</configsection>



Then we need to setup the castle section that we just defined like so:

<castle>
  <facilities>
   <facility id="arfacility" type="Castle.Facilities.ActiveRecordIntegration.ActiveRecordFacility, Castle.Facilities.ActiveRecordIntegration" isWeb="true" isDebug="false">
    <assemblies>
     <item>[assembly_name_to_init_AR]</item>
    </assemblies>
    <config>
     <add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
     <add key="dialect" value="NHibernate.Dialect.MsSql2005Dialect"/>
     <add key="connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
     <add key="connection.connection_string_name" value="[connection_string_name]"/>
     <add key="proxyfactory.factory_class" value="NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle"/>
     <add key="query.factory_class" value="NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory, NHibernate"/>
    </config>
   </facility>
  </facilities>
 </castle>

if you want to use just active record without the IoC and facilitator you just need:

<section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" />
instead to the configuration section and the following:

<activerecord 
        isWeb="true|false" 
        isDebug="true|false" 
        pluralizeTableNames="true|false"
        threadinfotype="custom thread info implementation"
        sessionfactoryholdertype="custom session holder implementation"
        namingstrategytype="custom namingstrategy implementation">

        <config
            database="MsSqlServer2000|MsSqlServer2005|MsSqlServer2008|SQLite|MySql|MySql5|Firebird|PostgreSQL|PostgreSQL81|PostgreSQL82|MsSqlCe|Oracle8i|Oracle9i|Oracle10g"
            connectionStringName="name of connection string in config">
            <!-- Any legal NHibernate parameter you want to specify or override its default value -->
        </config>

        <config type="Full Type name to Abstract Class that defines boundaries for different database">
            <add key="connection.driver_class"           value="NHibernate Driver" />
            <add key="dialect"                           value="NHibernate Dialect" />
            <add key="connection.provider"               value="NHibernate Connection Provider" />
      <!-- Use only one of the two attributes below -->
            <add key="connection.connection_string"      value="connection string" />
            <add key="connection.connection_string_name" value="name of connection string in config" />
        </config>
        
    </activerecord>


this is described in nice detail on the castle website

The last step would be to use the global.asax.cs file and on Application_Start do:

//init windsor IoC container
            Castle.Windsor.WindsorContainer container = new Castle.Windsor.WindsorContainer(new Castle.Windsor.Configuration.Interpreters.XmlInterpreter());
            

Now adding classes for automated DI is just as simple. In the same init method you would do the following:

container.Register(Castle.MicroKernel.Registration.Component.For<[class_name_here]>());

To recall a class you just make a setter in another class that has been injected. If you want access from a class that was not injected by Windsor you would do the following:

container.Resolve<[class_name_here]>();


Not so bad huh?

Wednesday, October 27, 2010

Continuous integration server with Hudson for Java, .NET and beyond.


Continuous Integration and Automated Build Environment...

We all know it's super awesome and we need to have this practice. The point of this post is simple. How to get hudson (very simple continuous integration server) up and running to checkout (from svn, git, etc) and build your java (maven, ant) or .net (nant) projects at light speed.

First download the hudson.war from http://hudson-ci.org/. You will need jre 1.5+ and ........that's it! No DB no configuration no nothing!!!! Hudson stores your setup under ~/.hudson in xml files but for all practical intents and purposes you don't need to worry about it.

start the embedded jetty by typing the following in your terminal:

java -jar hudson.war

This will start jetty at http://localhost:8080

Go to that URL in your browser. You should see something like this



Now if your using git you need to install the git plugin. Go to the nav bar on the left and then to manage hudson->manage plugins. Here you can install the git plugin (as well as the nant plugin if your working in .net).

Lastly, you create a new job. When you create a new job you can go to configure and fill out the easy to follow GUI form.

That's it!

Thursday, October 21, 2010

Goodbye MS Visual Studio & .NET, Hello Mono Stack + Lucid Lynx!

I'm originally from the MS world. Don't fault me it was the time that I grew up. My generation had pretty much grown up eating up MS products without any knowledge of anything else. So naturally while doing a CS undergrad I learned classic ASP and out of school started with .NET 1.1.

The last two or so years I've had the pleasure of working at a company that is solely open source. At first I hated it. Everything seemed soooo much harder. You had to configure this and configure that and I absolutely hated the linux command terminal. Little did I know it was my ignorance that made me hateful. Not before long, I fell in love with the terminal. Then I fell in love with Java and JEE. Open source simply fits the personalities of true developers better. I would of told present day me off 2 years ago, but it's true. MS creates inferior developers.

Anyway, recently I got a project that was .NET. I had heard of Mono before but I actually got a chance to work with it. Let me tell you that it's awesome!!! Sure it doesn't have all the bloat that VS has but that bloat is unnecessary anyway for most things I work on. It's faster than VS2008. NUnit hooks in beatifully, unlike the MS Test project that is super bloated and slow. It has all types of engineering goodies like LOC, Cyclomatic Complexity, etc.

Anyway for the full stack you gotta get:

1. Mono - Runtime
2. MonoDevelop - IDE
3. MonoDevelop-Nunit - NUnit integration for IDE
4. Nunit - Command line NUnit
5. NAnt - Build tool
6. XSP2 - Mini Web/App server for asp.net

If your on Ubuntu 10.04 follow these steps:

1. Add deb
http://badgerports.org lucid main
to
/etc/apt/sources.list
2. Run following commands

gpg --keyserver http://badgerports.org/directhex.ppa.asc --recv-keys 0E1FAD0C
gpg --export --armor 0E1FAD0C | sudo apt-key add -
sudo aptitude update
sudo aptitude install monodevelop
sudo aptitude install monodevelop-nunit
sudo aptitude install nunit
sudo aptitude install nant
sudo aptitude install mono-xsp2

That's it. I guarantee it'll be installed before you get through the first 5-10 minutes of VS2008 if you have good bandwidth.