The Library

21 04 2008

Ah, the library grows once again. I either need less books, or a bigger shelf. Its even starting to bow from the weight. And its out of room. Damn….





Microsoft – It’s a Love Hate Relationship

20 03 2008

So first off, let me say, I’m pretty neutral about the different major Operating Systems. I like Windows for surfing, programming, and basic stuff.

I like Macs for their power with photo and video editing and unique and creative features.

I like linux for programming, and using as a server. It’s quite good at those things.

So now we can see some of the nice things about each. Now for most of my computers I’m running windows. (except 2 that are running ubuntu  server) The reason for this is because I’ve been doing so much programming in the last few weeks. I’m putting out about 300-400 lines of code a day.  Thats a lot. Now, at this point you probably know that I’m going to talk about the .NET framework and the Visual Studios IDE’s. I really REALLY hate the .NET framework because it is Microsoft only, just like everything else Microsoft makes. Though with programs like Mono, which I talked about two or three posts ago, I don’t really have to worry about the portability of the .NET framework. So that is one thing that makes me happy about Microsoft; It is still portable despite the fact that they don’t want to be.

Despite those things, I still like the simplicity of most of Microsoft’s programs. Microsoft stuff like Office and Visual Studios are quite nice. They hog memory, but other than that they are very nice. I love Visual studios. It makes programming in any .NET language so much easier and the form designer is probably the best thing about it. Choose the things you want, and drag and drop them. The IDE is so great also for people like me who just wan to experiment. The intellisense in Visual Studios is very nice, and makes it easy to just explore the language itself so you don’t have to go looking through man-pages to find out how to use a function, and that is so convenient. Hooray,  Microsoft made something that I really like for once :]

I still hate Microsoft’s web site. It’s impossible to navigate…





C# Random String Generators

8 03 2008

Heres a little bit of code for making random strings. I’m sure someone will find it useful. I used to use it a lot in web development. Not sure how useful it would be for software development but use it if you’d like to :)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ruf
{
public static class StringGnerator
{
public static Char[] charArray = { ‘-’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘p’, ‘q’, ‘r’, ’s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’, ‘1′, ‘2′, ‘3′, ‘4′, ‘5′, ‘6′, ‘7′, ‘8′, ‘9′, ‘0′, ‘_’ };

public static string RandomStr()
{
String returns = “”;
Random r = new Random();
for (int i = 0; i < 11; i++)
{
returns += “” + charArray[(int)(r.NextDouble() + 1.0 * 38.0)];
}
return returns;
}

public static string RandomStr(int Length)
{
String returns = “”;
Random r = new Random();
for (int i = 0; i < Length; i++)
{
returns += “” + charArray[(int)(r.NextDouble() + 1.0 * 38.0)];
}
return returns;
}

public static string RandomStr(int Seed, int Length)
{
String returns = “”;
Random r = new Random(Seed);
for (int i = 0; i < Length; i++)
{
returns += “” + charArray[(int)(r.NextDouble() + 1.0 * 38.0)];
}
return returns;
}

}
}





C# And .dll’s

14 02 2008

I’ve been working on Fizzure A LOT recently. I made a FizzSrvLight that is not a distributed system like the regular one, which therefore allowed me to write one effectively in about 3 hours. On the way I decided to make a few of my own methods and then realized, hey these can be used in other projects too!

So I made a class library (.dll – Dynamically Linked Library ) with a few methods that have to do with TCP Data transmition. The most important of which is the Send method that I made. Now this is really only useful for the client. Anyway, heres the snippet:


public static void Send(TcpClient Client, String Command)
{
Console.WriteLine("Opening Server Stream");
NetworkStream n = Client.GetStream();
String send = Command;
String receive = null;
byte[] msg = System.Text.Encoding.ASCII.GetBytes(send);
n.Write(msg, 0, msg.Length);
Console.WriteLine("SENT: {0}", send);
}

this method is meant for console programs, but if you are using a GUI all you really need to do is delete the Console.WriteLines()’s in there and replace it with wherever you want the output.

Hope this is helpful to everyone!





C# TcpListener Example

13 02 2008

Ok, this is just a quick snippet of code I wrote to get a working server up. Obviously theres more commands I could put in there in plenty of different ways, but I really just wanted to keep things simple for now. This took me about 2 hours.

This snippet is the main body of code that controls everything. If you go through it and read you’ll see that I made a struct to hold the information on files named File, in the namespace Structure. So you would access it by saying in this [MainNamespace].Structure.File; or you can just use Structure.File. I’ll paste the code for the struct at the end.

I didn’t leave too many comments because I used a lot of Writelines to tell me what it was doing, and for debugging purposes. Those kind of tell you what things do what.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace FizzSrvLight
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“FizzSrvLight :: Non-Distributed Fizzure Serving Capabilities”);
System.Threading.Thread.Sleep(1000);
Console.Write(“Loading…”);
Console.WriteLine(“!”);

Console.WriteLine(“Initiating Server Variables…”);
System.Net.IPAddress localaddr = System.Net.IPAddress.Parse(“127.0.0.1″);

Console.WriteLine(“Constructing Server Objects…”);
System.Net.Sockets.TcpListener MainServer = new System.Net.Sockets.TcpListener(localaddr, 9000);

Console.WriteLine(“Starting Server…”);
MainServer.Start();

Byte[] bytes = new Byte[1024];
String data = null;
String send = null;

while (true)
{
Console.WriteLine(“Waiting for connection…”);

// Accept Requests
System.Net.Sockets.TcpClient client = MainServer.AcceptTcpClient();
Console.WriteLine(“Client Connected!”);

// Clear Buffers
data = null;
send = null;

// Get Stream Object for reading and writing
System.Net.Sockets.NetworkStream stream = client.GetStream();

int i;

// Initialize File Holder
System.Collections.ArrayList CurrentFiles = new System.Collections.ArrayList();

// Loop to recieve all data sent from client
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
// Clear buffers again
data = null;
send = null;
string message = “OK”;
// Get data as string
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
Console.WriteLine(“FIZZ_RCV: {0}”, data);

String[] command = data.Split(‘ ‘);

// Insert Possible Commands Here
if (command[0] == “FIZZ_ADDFILE”)
{
FizzSrvLight.Structure.File file = new FizzSrvLight.Structure.File(command[1], command[2], command[3], command[4], command[5], command[6]);
CurrentFiles.Add(file);
}
else if (command[0] == “FIZZ_RMVFILE”)
{
FizzSrvLight.Structure.File file = new FizzSrvLight.Structure.File(command[1], command[2], command[3], command[4], command[5], command[6]);
CurrentFiles.Remove(file);
}
else if (command[0] == “FIZZ_AUTH”)
{
string username = command[1];
string password = command[2];
}
else
{
Console.WriteLine(“FIZZ_INVALID_INPUT”);
Console.WriteLine(“Error Handled”);
message = “ERROR”;
}

send = message;

byte[] msg = System.Text.Encoding.ASCII.GetBytes(send);

// Send back an OK response;
stream.Write(msg, 0, msg.Length);
Console.WriteLine(“FIZZ_SND: ” + message);
}
System.Threading.Thread.Sleep(1000);
}
}
}
}

Now, time for the struct.

namespace FizzSrvLight
{
namespace Structure
{
public struct File
{
public string FileName;
public string FilePath;
public string FileType;
public string SharedBy;
public string IPAddress;
public string Blacklist;

public File(string name, string path, string type, string user, string ipaddr, string blacklisted)
{
FileName = name;
FilePath = path;
FileType = type;
SharedBy = user;
IPAddress = ipaddr;
Blacklist = blacklisted;
}

}
}
}

Well, there you have it. A very simple TcpListener Serve. Obviously theres better ways to do it but this is pretty simple, straight forward, and just all around easy. Please leave comments if you find bugs in it or see errors or even if you just don’t understand what some of it does.





You Know You’re A Geek When…

10 02 2008

If I could find my camera, I would have some funny pictures to go along with this. but I don’t.

You know you’re a geek when:

  • You hang fuzzy dice from computer equipment.
  • You change the entire theme of all of your computers to the current holiday.
  • The number of computers you own is greater than the number of relatives you have.
  • You have informally taken over a room in your house just for you and your computers. (this only applies to people who still live with parents. Speaking of which…)
  • You’ve graduated and still live with your parents.
  • You rearrange your computers daily to try and make them look just that much cooler.
  • You’ve reformatted a Windows machine so many times, you know the serial number by heart.
  • Your computer room more than triples your electricity bill.
  • You have more Technology/Programming books than all of the other books you’ve ever read in your entire life.
  • You have an entire room full of spare computer parts.

Well, I could go on probably but i think I’ll stop here. 95% of these apply to me. I guess I’m a geek. Who else is?





Thoughts About Distributed Computing

20 01 2008

For me, distributed and parallel computing is one of the most interesting areas in computer science that I have found so far. I would really love to do work/research with it.

Distributed and Parallel Computing, at least from how I see it, seems to be the future of computers and processing power. Processors are starting to reach towards their physical limitations. So instead of making one processor even better, why not just use several, or even hundreds.

Slowly, I’m putting together my spare parts that I have at home into more computers to use. I got two more working in the last 2 days, both of which are semi decent machines. The main thing that I want to do with them is to try to make some of my own distributed applications that will be able to spread its processes out over several computers. Right now I have 3 computers that I want to use in my distributed system, the most powerful of which will be the main computer that is in charge of assigning the tasks. the other two, which are not as powerful, but still can handle plenty, will be sent instructions that will be processed and then they will send results back to the main server.

Now seeing as the 2 secondary nodes that will be in the system do not have the same specs, I have to make sure the server pays attention to the % of their resources that are being used when it goes to assign instructions. If the slower computer has been assigned less, but is using more of its resources, the next task that needs to be processed will be sent to the other computer.

Currently both of my secondary nodes are running Windows XP. This is fine I guess, but it seems like a large waste of system resources to have to run full windows. Though I realize that there is no way in hell that I can actually do this, I would love to write my own very basic OS just to handle being a secondary node in a distributed system. A node that when it turns on, simply connects to the central server, waits for its tasks, and then executes and sends back reports. No need for hogging resources with a gui or anything. All that is particularly necessary is enough to execute instructions and send/receive data over the network. But, when you actually think about it, that would take a very long time for me to figure out how to do. I don’t know the first thing about where an operating system starts really. Maybe I could use a linux kernel and just build off of that and get rid of things that aren’t really needed. I need to do a lot of research on this one.

This seems like it has the opportunity to be extremely efficient. Just a lightweight OS meant solely for being a secondary machine in a distributed  system would be so much faster than running anything i could create as a windows application. Unfortunately, I don’t know where to begin. Maybe I will set this one aside as a very long term project, slowly do research on it, and spend the bulk of my time on other projects are already have going like Fizzure. Haven’t worked on that one in a few days. Need to get back to it. I’ve been doing some little practice applications with sending and receiving data with the TcpClient and TcpListener class in C#. Now that I think I have a much better handle on how those work, it should be much easier to get over the hurdle I was stuck on with Fizzure.

Another goal I have is to make the Fizzure central server able to be split into nodes. Have different sections of all the XML data to be searched stored on different nodes. when a query comes in, the server sends a request to each node, each node searches the part of the data that it has stored and returns its results to the server, which than returns all of the results to the client. This seems more efficient than just having it all done by one computer, though because of network bandwidth, I don’t quite know if it would be in actuality.





What Would I Do With A Million Dollars?

15 01 2008

I saw a post yesterday about what someone would do with a million dollars. He said he would buy some crazy macs of course. The specs were amazing. Reading that post got me thinking though – What would I do with a million dollars?

After about a good 30 seconds or so, the answer was quite clear. I would make my own data center, duh!

And of course I would save several servers for my own private use for research on Distributed Computing. Because I think that is really interesting and would love to do work with it in the future.

Anyways, I immediately set out to find some hardware that I would use in my new Data Center.

The first thing that you would need obviously is for a Data Center would be a place to hold data. So I found this:
LACIE 300961 2TB Gigabit Ethernet Shared Hard Drive

Connects through a 10/100/1000 Ethernet port, and each has a 2TB capacity. VIA C3 800Mhz processor and 256MB of RAM.

Price Per Unit: $859.99

Quantity: 100

Total Cost: $85,999.00

After buying these i would now have $914,001.00 left to play with. Time for some processing power.

I put together a custom rack. Quite powerful in my opinion. Heres the specs:

Custom Rack Unit

CPU:
2 x Intel Xeon X5450 Harpertown 3.0GHz Quad-Core Processor

2MB L2 Cache

1333 Mhz FSB and 64 bit support

Motherboard:

TYAN S5397AG2NRF Dual 771 Extended ATX Server Motherboard

Dual 771 CPU Sockets

1600/1333/1066 Mhz FSB

16 x 240 pin DDR2 Memory Slots

1 PATA / 6 SATA II

3 x On-Board Gigabit LAN
RAM:

Kingston 2GB 240-pin DDR2 SDRAM PC-5300 Server Memory

2GB Capacity

PC-5300 Speed

Power Supply:

iStarUSA TC-350R2U 2 x 320w Server Power Supply

24 Pin Power Connector

2 x 350 Watts

2 Fans

Of course, to wrap it all up, I need a case…

Case:
iStarUSA D-200-PFS Black Steel 2U Server Case

1 External 5.25″ Drive Bay

1 External 3.5″ Drive Bay

2 Internal 3.5″ Drive Bays

3 Expansion Slots

2U Form Factor

2 x 80mm Fans

Price Per Unit: $3,875.82

Quantity: 100

Total Cost: $387,582.00

Ok, so now at this point, I have $526,419.00 left to spend. Haven’t even spent half yet.

What is the next thing that any Data Center needs? Internet of course. The data center is no good if no one can access it.

If I were to get 30/15Mbps service, It costs $239.99/month for a 2 year agreement. which comes out to be $5,760 for two years. leaving me with $520,659.00

Now that seems like a large amount of money, but if you really think about it. I would probably use the rest for an office/building, utilities, and repairs and maybe some employees. So now that I look at it, starting a Data Center would be hard because you end up spending more money on other things and less on actual computers. That’s disappointing.





w00t – Great Success

9 01 2008

I know for most professional programmers and really anyone else in general it isn’t much of an accomplishment, but for me this is – I got the basic TCP connection working between the Fizzure client and server.

The server is just a lightweight console application. So far all it really does is accept connections. But for now I guess thats good enough. Today, I need to work on the XML usage of both the client and the server, and then the interaction with XML between the two. For efficiency I think I will do a lot of caching data. But I guess I need to figure out how to do that as well. I’m going to have to do a little more planning and deciding before I do too much programming.

Also though, I need to work on the GUI for the client.  I’m thinking about making it kind of skinnable. Or at least it will have different like color themes you can choose from. But eventually, I want it to be skinnable. People do seem to like that, it makes you feel like your program is just that much more personalizable.





Fizzure Will Go Open Source – When It’s Ready That Is

7 01 2008

I have decided that my peer to peer application, Fizzure, will be open source! Exciting, I know.

However, I don’t think that I will open the source until I have a working beta build. Right now its still in core development. And it has a long way to go. Only the client will be open source. The central server that all will keep the information organized will be private and closed source. Sorry fellas. Out of luck on that one.

Fizzure will be the first application that I will publish officially, so I’m not completely sure how to go about doing so. My friend suggested that since I’m opening the source I should put it under the GPL. Sounds like a good idea, but, how do I do this? If anyone has suggestions for a n00b like me on how to go about doing such that would be great. If not, I’m going to ask again later anyways, once it is closer to an actual release.