The Unix Divide

HP-Unix

May 12, 2009 · Leave a Comment

Besides simply being a proprietary configured version of Unix, I’m noticing some other general qualities, and one of them is RPC. The RPC offers C routines, written into the OS I suspect, that you can call. It’s interesting how it says at the end of the help screen that it was RPC was developed by Sun Microsystems.

There are lots of RPC commands that come with this HP machine, and they are binary files.   Perhaps some of these things nowdays are built into the normal quoatd or mountd commands, for example, in Linux.

/usr/etc/yp contains info about and the NIS server commands, also developed by Sun.

The thing you’d want to still use a Unix system for would be C programming or the numerous command-line utilities along with shells.  There are Bourne, Korn, C, and Key shells;  I don’t remember Linux having as many command-line utilities, either.  cc means C compiler, but CPP does not stand for C++, instead it stands for C pre-processor, which handles your macros before the straight C compile.

BASH is actually a superset which can process most BOURNE scripting as well.  Korn and C shell are simply an apt-get away on Debian based Linux installs – ksch and csh.

Also, I notice credits given in HP-Unix to MIT, Berkely BSD, Cornell, Sun, etc., which re-inforces the notion that once the AT&T code had been replaced, *nix was off and running.  Unix became a certification rather than a single OS.  When I think of HP-Unix, I think of a customized distro, it has a ‘SAM’ utility to help configure your config files for you, etc.

→ Leave a CommentCategories: Uncategorized

Home network and skills

April 18, 2009 · Leave a Comment

I have three PCs. One is a Slackware server, one is an Ubuntu desktop, and the other is a Windows2k desktop. I develop on my Ubuntu machine, and Slackware is for my back-end.

I have hosted servlets on Slackware, and also PHP-driven DB and Ajax example.

Right now I want to make a DB-driven project for either a Servlet or for PHP, and preferably both. With PHP, it would be more javascript focused, and with JSP, more back-end focused.

I need to be focused on adding Javascript and probably Ajax as well.

→ Leave a CommentCategories: Uncategorized

GnuChess code

March 8, 2009 · Leave a Comment

/* GNU Chess 5.0 – util.c – utility routine code
Copyright (c) 1999-2002 Free Software Foundation, Inc.

GNU Chess is based on the two research programs
Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.

GNU Chess is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Chess is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Chess; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place – Suite 330,
Boston, MA 02111-1307, USA.

Contact Info:
bug-gnu-chess@gnu.org
cracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net
*/
/*
* Endianness checks are now unnecessary
*/

#include
#include
#include

#include “common.h”

/*
* We actually do not have this configuration variable yet,
* should be manually added when inlining is not possible.
* If inlining is possible, these functions have now moved
* to util.h which must be included by all callers of
* leadz() and nbits().
*/

#ifdef NO_INLINE

unsigned char leadz (BitBoard b)
/**************************************************************************
*
* Returns the leading bit in a bitboard. Leftmost bit is 0 and
* rightmost bit is 63. Thanks to Robert Hyatt for this algorithm.
*
***************************************************************************/
{
if (b >> 48) return lzArray[b >> 48];
if (b >> 32) return lzArray[b >> 32] + 16;
if (b >> 16) return lzArray[b >> 16] + 32;
return lzArray[b] + 48;
}

unsigned char nbits (BitBoard b)
/***************************************************************************
*
* Count the number of bits in b.
*
***************************************************************************/
{
return BitCount[b>>48] + BitCount[(b>>32) & 0xffff]
+ BitCount[(b>>16) & 0xffff] + BitCount[b & 0xffff];
}

#endif /* NO_INLINE */

void UpdateFriends (void)
/***************************************************************************
*
* Update friend and enemy bitboard.
*
***************************************************************************/
{
register BitBoard *w, *b;

w = board.b[white];
b = board.b[black];
board.friends[white] =
w[pawn] | w[knight] | w[bishop] | w[rook] | w[queen] | w[king];
board.friends[black] =
b[pawn] | b[knight] | b[bishop] | b[rook] | b[queen] | b[king];
board.blocker = board.friends[white] | board.friends[black];
}

void UpdateCBoard (void)
/**************************************************************************
*
* Updates cboard[]. cboard[i] returns the piece on square i.
*
**************************************************************************/
{
BitBoard b;
int piece, sq;

memset (cboard, 0, sizeof (cboard));
for (piece = pawn; piece <= king; piece++)
{
b = board.b[white][piece] | board.b[black][piece];
while (b)
{
sq = leadz (b);
CLEARBIT (b, sq);
cboard[sq] = piece;
}
}
}

static const int OrigCboard[64] =
{ rook, knight, bishop, queen, king, bishop, knight, rook,
pawn, pawn, pawn, pawn, pawn, pawn, pawn, pawn,
empty, empty, empty, empty, empty, empty, empty, empty,
empty, empty, empty, empty, empty, empty, empty, empty,
empty, empty, empty, empty, empty, empty, empty, empty,
empty, empty, empty, empty, empty, empty, empty, empty,
pawn, pawn, pawn, pawn, pawn, pawn, pawn, pawn,
rook, knight, bishop, queen, king, bishop, knight, rook };

void UpdateMvboard (void)
/**************************************************************************
*
* Updates Mvboard[]. Mvboard[i] returns the number of times the piece
* on square i have moved. When loading from EPD, if a piece is not on
* its original square, set it to 1, otherwise set to 0.
*
**************************************************************************/
{
int sq;

for (sq = 0; sq -1)
{
sq = board.ep + (xside == white ? 8 : -8);
if (!(BitPosArray[sq] & board.b[xside][pawn]))
return (false);
}

if (board.flag & WKINGCASTLE)
{
if (!(BitPosArray[E1] & board.b[white][king]))
return (false);
if (!(BitPosArray[H1] & board.b[white][rook]))
return (false);
}
if (board.flag & WQUEENCASTLE)
{
if (!(BitPosArray[E1] & board.b[white][king]))
return (false);
if (!(BitPosArray[A1] & board.b[white][rook]))
return (false);
}
if (board.flag & BKINGCASTLE)
{
if (!(BitPosArray[E8] & board.b[black][king]))
return (false);
if (!(BitPosArray[H8] & board.b[black][rook]))
return (false);
}
if (board.flag & BQUEENCASTLE)
{
if (!(BitPosArray[E8] & board.b[black][king]))
return (false);
if (!(BitPosArray[A8] & board.b[black][rook]))
return (false);
}

return (true);
}

————————————————————————————————-

My commentary:

This is a very interesting program because it’s the fastest program I’ve ever seen that wasn’t written in assembly.

It uses a bitboard, a 64 bit ‘Long’ variable in C.

board.friends[white] =
w[pawn] | w[knight] | w[bishop] | w[rook] | w[queen] | w[king];

Here there are 6 bitboards because you can have multiple rooks on different squares, pawns, etc. (only exception is the king, only one of them per side).  So what this code does is OR all of the bitboards together to create one bitboard of all of your pieces.

Can you imagine doing this like a CRUD app in Java.  You’d have a “collection” of boards, and foreach through all of them to add to a “master” board, or something like that.  haha, slow.

Here’s another bit of code.  If your king has already moved (or the rook), then it can’t castle, so you need to check for that (once you castle, a flag is set so it won’t need to keep checking this):

if (board.flag & BKINGCASTLE)
{
if (!(BitPosArray[E8] & board.b[black][king]))
return (false);
if (!(BitPosArray[H8] & board.b[black][rook]))
return (false);
}

So for example, is there a rook on H8, supposing you want to castle to that side?  Well, this is a 64 bit board, a long, so you can’t just look for one value right, because there could be many other rooks all over the place, and you only care about whether or not that one rook (bit) is in a position that will allow the king to castle there, you don’t care to compare all the other bits (positions).  So, you use an AND that will only tell you if the bit in the first Long that you are checking for is found in the second Long.  All of the other bits drop out because it is an AND comparison and only the ones in common stay.

Note:  A Long in C is 8 bytes, so 8×8 =64 bits (board squares, conveniently).  Also, I did not write this code, just downloaded the source code and studied some of it.

→ Leave a CommentCategories: Uncategorized

Coding

February 27, 2009 · Leave a Comment

I’m going to code this little program right now that concatenates the content of files into just one file.  I should probably be using a Unix utiilty for this rather than coding it in Java or Perl.  Maybe I should do it an all three.

→ Leave a CommentCategories: Uncategorized

Servlets

November 9, 2008 · Leave a Comment

For all my reading about them a couple months back, I just got my first one to work. Set it all up on Slackware and went through the usual problems/issues of learning the Tomcat setup with Linux. Spent a large block of time and never lost any motivation, got stressed or tired. That like never happens. :-)

Got a JSP to work now; nice to know that it all works. I’ve been going through the Head-First book on servlets&JSP.

My goal is to create a working web-app for a portfolio that I can use to display my abilities.  First part I did was to create a DB schema for a hypothetical plant that assembles PCs, and that took quite a while to get straight as I was used to sql, but not designing databases.

→ Leave a CommentCategories: Uncategorized

Javascript

September 1, 2008 · Leave a Comment

I’m reading the Wrox book on ‘Beginning Javascript’ and it’s really good so far.  I’m going to pick up Ajax as well for my latest job-search, to compete for all the web jobs out there.

But ultimately, PHP and .net are the hottest right now on the serverside.  Java web jobs want so much experience, even though I feel well-versed and experienced in core Java.

Perhaps once I’ve secured a job as a web-programmer, I’ll try to pick up Swing on the side, or maybe that will come after the Javascript and Ajax.  Going to be doing a lot of studying.  If I could be just capable enough to do consulting work, then that might also work.  Will keep this blog posted.

→ Leave a CommentCategories: Uncategorized

Swing

January 28, 2008 · Leave a Comment

This is cool:

http://beginnersjavatutorials.blogspot.com/2008/01/java-swing-example.html

Make the textbox go larger than the frame.  What I like is that the Java compiler told me why it wouldn’t run this code at first, and so I fixed line 7 to read:

frame.getContentPane().add(panel);

→ Leave a CommentCategories: Uncategorized

Java

January 6, 2008 · Leave a Comment

Is quite cool after all. 

I had an epiphany about a week ago because I wanted to use pointers in Java, or at least a hash from Perl.  Well, luckily the JavaCollection library has things like HashMap, which does the same thing.  Now it looks like I’ll have to sort it with an ArrayList. 

The main purpose for using these “pointers” is to allow the code to handle dynamic situations, where the results of some operations aren’t know in advanced (like with just plugging in an enum, instead).

People keep saying Java is an OO language only, but you can use static methods and vars, and then it’s just like using a code module in VB or Perl, conceptually.  It’s the lack of pointers that is limiting, that’s _why_ you end up using objects instead.

→ Leave a CommentCategories: Uncategorized

A beautiperl day

July 30, 2007 · Leave a Comment

I was all psyched to try out this Perl example using XML::DOM, but it didn’t work on either Windows or Linux.

CPAN got it installed on Linux, and ppm got it installed on Windows.  CPAN on Windows, not so great.  I guess it didn’t know to use nmake, so I tried it manually (Well first I had tried the whole process manually).  Then make install couldn’t find a command called ‘cl’.  ppm was effortless, and I already knew the prereqs for XML::DOM (in case that mattered).

I’m tasked with implementing a web survey.  At this point, I was already like okay, okay, I won’t use XML.  We’ll see if I can get a key guy there to install it for me.

“Give me root on your server!”  Grrrrr!  ;-D  Nah, this one guy is tops at doing that stuff, but he’s not technically an admin (full root).  CPAN needed root, probably because Perl is root.

The DOM seems to point out the entire object collection to the very end, like this: <contact><FirstName>joe</FirstName><LastName>blow</LastName></contact><contact><FirstName>sue</FirstName><LastName>smith</LastName></contact><contacts>

So what I need is to use SAX to make it look like a readable file, and later XSL to make a report-like version that is displayable, in human terms, to the browser as a web page.

→ Leave a CommentCategories: Uncategorized

Home-learning Setup

July 28, 2007 · Leave a Comment

I have a number of computers, but I think I’ve made my ideal choice. I am using a Slackware server, and soon I’ll just setup a barebones Windows desktop machine next to it.

Of course, I am typing this from an Ubuntu desktop (at another desk), but just for idealsies, I’ve made a separate arrangement.

Two reasons. 1. Thin desktop – I can run IE and Swing from. 2. Thick server – lets me run the server from an ideal server distro. Slackware is a completely different animal from the shrink-wrap, marketecture (got that word from xampl ;-) type of distro. The Debian based distros are alright, but they aren’t as hand-crafted, traditional Unix-like style, as Slackware.

Oh, I do learn and practice Swing on Ubuntu (Gnome), but the users at my co. (most businesses) have Windows desktops.  So I can tweak the final result, or watch web page results on a Windows machine.

→ Leave a CommentCategories: Uncategorized