Showing posts with label open source. Show all posts
Showing posts with label open source. Show all posts

Monday, September 20, 2010

UVOG Arcade Machine

Umpqua Valley Opensource Group is building a classic-style Arcade machine (with a few innovations.) I am in charge of drawing the sprites for one of the games, so I spent the weekend studying 8-bit video game palettes.

I settled on using limitations similar to the 8-bit NES. The NES itself only had around 54 possible colors on the system palette (technically there were 64 color indexes, but 10 of them were black and two were white!) There were also many additional limitations on how many colors could be used at a time on the screen as well as how many could be used per tile or sprite.

I am using the same basic ideas to restrict the artwork for this game, but I have created an expanded palette using a full range of 64 different colors. I also hand-tuned the choice of colors, and re-ordered the palette in a more sensible way.

Because the Arcade Machine is an Open Source Project, my palette is Open Source as well. I am calling it the UVPALETTE. It is available as a GPL (GIMP PaLette; which is usable in mtPaint also, and is basically a text file with a list of RGB values) at the following address:

http://communitycomputercenter.com/userfiles/UVPALETTE.GPL

I also have a demo of the palette here is a PNG file:


In order to make discussing and working with the palette easier, I have prescribed a canonical name for each color:

Names of colors on the first row (0x00 - 0x0F) Black, Dark Blue, Dark Cerulean, Dark Mint, Dark Green, Dark Lime, Dark Yellow, Dark Tan, Dark Orange, Dark Red, Dark Rose, Dark Orchid, Dark Violet, Dark Indigo, Forest, Charcoal.

Names of colors on the second row (0x10 - 0x1F) Gray, Blue, Cerulean, Mint, Green, Lime, Yellow, Tan, Orange, Red, Rose, Orchid, Violet, Indigo, Brown, Slate.

Names of colors on the third row (0x20 - 0x2F) Silver, Light Blue, Light Cerulean, Light Mint, Light Green, Light Lime, Light Yellow, Light Tan, Light Orange, Light Red, Light Rose, Light Orchid, Light Violet, Light Indigo, Jade, Chalk.

Names of colors on the fourth row (0x30 - 0x3F) Pale White, Pale Blue, Pale Cerulean, Pale Mint, Pale Green, Pale Lime, Pale Yellow, Pale Tan, Pale Orange, Pale Red, Pale Rose, Pale Orchid, Pale Violet, Pale Indigo, Gold, White.

Here is another version of the palette demo with the prescribed color names listed for quick reference:


Enjoy!

Tuesday, July 13, 2010

Open Database Conventions

I've been using a set of database table and field naming conventions and related standards that have been gradually adopted and refined over the last 10 years. I decided today that it would be a good idea to share these with others, particularly because I decided to bring Jim from UVOG in on a database project I'm starting on. I realized that sharing them with others on an even wider scale might be a good thing on the off-chance that, if someone else out there adopts them, and if our code ever ends up crossing paths, we will gain greater interoperability and understanding on account of using the same techniques.

Feel free to take some or all of these ideas and implement them in your own projects. I am willing to hear feedback and incorporate it back into the standard if you think there's a better way to do something that I've mentioned.

Some of these conventions will apply specifically to MySQL, while others will apply to the greater spectrum of databases. My experience spans MS Access, MS SQL Server, dBase, FoxPro, the Apollo Database Engine, and MySQL, with some very light experience in SQLite and PostgreSQL, but the bulk of my work today happens in MySQL.

Naming the Database

The name of the database itself is the least of my concerns. I would just recommend that in code that operates with or upon the database, this value should be easily configurable along with the hostname, port, and authentication credentials, so that any database could be selected.

Naming Tables

The name of a table should be a succinct name descriptive of what is to be represented by a single record in the table. If each record in the table represents an account, for example, name the table "account" (in the singular, all lowercase.) The reason we use singular forms is so that dot notation naming of fields makes sense when read out loud, for example, account.balance. There are many reasons we use all lowercase. Most production Database servers are case sensitive, and by using all lowercase we can eliminate the possibility of an error relating to case. It also improves code readability when SQL statements are written out with keywords and function names capitalized and with table and field names in lowercase.

There is a special case of naming in the event of a junction table. (A junction table is used to create a many-to-many relationship between two tables, and consists of nothing more than an id field, and foreign keys for the two tables whose records it is tying together.) The name of a junction table should be the name of the other two tables mashed together, with the name of the greater entity first. For example, if I have a company table and an customer table, and customers are potentially associated with multiple companies, I would name the junction table companyemployee, and it would contain id, kcompany, and kemployee, in that order. If there is a toss-up in determining which entity is "greater," place the two table names in alphabetical order.

Naming Fields

Always name your fields as though they are going to be used in dot notation. We want account.balance, not account.accountbalance, so do not redundantly repeat the table name within the field name. Avoid abbreviations that seem like a hack. For example, number is better than "no" or "num." Widely used abbreviations like ipaddress, ssn, or id are ok--be particularly careful to avoid expanding acronyms that are not expanded in common speech.

The Primary Key

In order to be properly maintained, every record needs to be addressable by a unique identifier. This identifier should not be meaningful in any real-world way for reasons that are explained in depth elsewhere, but I will give one brief example. If you were making an employee database, you might be tempted to use a person's SSN as the primary key for the employee table. Three years after the program is written, your company might hire someone who is in the country on a work visa, and therefore does not have an SSN, and now your system is broken. One will follow this line of thinking out and conclude that the key should be completely arbitrary and meaningless so that no such conflicting situation may ever occur. Additionally, for the sake of consistency, the primary key field in each table you make should be of the same name and type. I recommend naming the first field of each table "id", setting it to "auto_increment," and setting it to become the PRIMARY KEY index.

The value of this id field should be used internally for programming purposes and for describing relations between tables, but it should never be shown prominently to the user. If it is shown, it is merely for debugging or reference purposes. The number in this field, once generated, should not be changeable by the user, is not guaranteed to be sequential with the records around it, and is not guaranteed to fall into any range of values more specific than those allowed by an int (11) field.

Foreign Keys

A foreign key can be thought of as a "pointer" referring from the current record out to another record in another table (or possibly another record in the same table.) All foreign keys should be prefixed with the letter "k" (meaning key), and should either be named "parent" if the key is referring back to the same table for the purpose of producing a hierarchical system, or if referring to another table, it should be given the name of the table into which it points. If more than one key in a record must point to the same table for different purposes, the purpose should be appended to the name followed by an underscore. For example, kaddress_from and kaddress_to would be pointers to two records in the table named "address." The relation to one of them is described as "from" and the other as "to." This is the only time an underscore is permitted to be used in a field name, and the purpose of the underscore is to make the table name unambiguous.

When possible, try to put keys to parent records or records which are considered to "own" the current record near the top of the field listing, following just after id.

If these standards are followed for the primary key and foreign key fields, I could look up any reference using the following technique:

Given a field whose name begins with "k": Take everything in the field name following the "k" up to the end of the name, or up to (but not including) the first encountered underscore "_" character, and consider this to be the "lookup table name," if such a table exists. Retrieve the data by issuing a query in the form of:

SELECT * FROM [lookup table name] WHERE id = [value of the field]

Choosing Appropriate Data Types for Fields

Always choose the most restrictive type that can safely store the data, including valid values that you might not anticipate.

KEY FIELDS

For id fields or foreign key fields, use INT (11)

For boolean (yes/no or true/false) fields, use TINYINT (1) A value of zero means false, and any nonzero value means true. You can distinguish between individual nonzero values for record housekeeping if you wish, as long as others reading the data as merely true or false will not be under a misconception from not making such a distinction.

CURRENCY

For currency values less than a million dollars, use DECIMAL (8, 2) --- increase the first size by a sufficient number of digits if you need larger currency values.

NUMERIC DATA

For numeric data involving whole numbers or integers only, use INT (11) --- unless the size is astronomical, in which case, you will need to upgrade to a larger type.

For weights or non-integer quantities less than ten thousand, use DECIMAL (8, 4) --- increase the first size if values beyond ten thousand are needed, or both sizes if more precision than four decimal positions is needed. Four decimal places was chosen so that a number like 12.05% could be fully represented as 0.1205.

DATES AND TIMES

For date or time values or stamps where the "time part" has meaning (particularly in sorting), use the DATETIME type. A value of "0000-00-00 00:00:00" means not entered or unknown.

For date values where the time is irrelevant, use the DATE type. A value of "0000-00-00" means not entered or unknown.

MULTIPLE CHOICE

For multiple choice values: If there are a discrete number of choices presently and in the near future, few choices (about 8 or less), and little or no benefit would be had by allowing the user to customize the set of choices, an enumerated value may be used. Example: alignment ENUM ('left', 'right', 'center') DEFAULT 'left'

For multiple choice values where the choices are numerous or user defined or potentially user managed, a foreign key and a lookup table should be used instead of an enum.

STRINGS OF TEXT (NO MULTI-LINE VALUES)

For any string data: If the options are very well established, choose the smallest size category from the table below that can hold all possible values, or for data that is free-form, choose one category larger than you think is really necessary. I will give some example with each size category:

VARCHAR (4) -- A standard name suffix like Jr., Sr., II., III.
VARCHAR (8) -- Data known for certain to be less than or equal to 8 characters.
VARCHAR (16) -- A zip code. (Minimum to store a US zip code is presently 9 digits plus one hyphen.)
VARCHAR (24) -- A phone number, with decorations. The following number is 23 characters long, including spaces: +1 (541) 375-0448 x8888
VARCHAR (32) -- Product codes, SKU numbers, or generated numbers that are guaranteed to be less than or equal to 32 characters.
VARCHAR (48) -- A first(given) name by itself, or a last name(surname) by itself.
VARCHAR (64) -- A full name field (first and last name together.)
VARCHAR (128) -- An email address.
VARCHAR (248) -- A web address.

PARAGRAPHS OF TEXT, NOTES, MESSAGE CONTENT, CODE SNIPPETS

For anything multi-line, or potentially longer than 248 characters, use the TEXT type. If the data or text will be more than a couple of kilobytes, investigate the LONGTEXT type.

IMAGES OR BINARY FILES

I don't like big files taking up space in my InnoDB tables and slowing down my replication server. Instead, I store the original filename only (and only as a convenience) in a VARCHAR field, and then save the file separately named based upon the table name and record number the file is associated with. If I need to replicate these files, I let rsync take care of that. If the "attached" files MUST be synchronized with the other data in the record at any given moment, then it might be acceptable to resort to BLOB fields.

Order of Fields

When creating tables, the order of the fields really doesn't matter to the database engine. The sequence, therefore, should be chosen for purposes of clarity in documentation.


Well, that's all I have for now. Have at it, tear it up, and send me suggestions.

Thursday, January 1, 2009

My Comprehensive List of Free or Open Source Software for XP

I received a brand new hard drive (400GB SATA) for Christmas this year (thanks Mike!), and so I am spending today reinstalling my main computer with Windows XP Pro. Unlike most Linux distributions, Windows is devoid of any useful programs after it has been freshly installed (no, I'm not saying that windows is a linux distro). As I reinstall all of my old programs, I'll be keeping track of them here for future reference, and maybe some passer-by (that's you) will find it useful.

I got tired of adding text and links about halfway through - I will update tomorrow or so.

The Operating System:


Windows XP Pro

Much better than XP Home, if you are going to use your computer in any custom way, or on a network. I'm not even going to go into Windows Vista here.

Debian, Etch

Debian will be installed as a dual boot on my 80GB drive... I've only used Mandriva and Ubuntu/Xubuntu thus far, so this will be exciting.

Appearance:


Royale Noir XP Theme

Download the Royale Noir theme and follow the instructions. This will give you a darker (navy or black) version of the Windows Media Center theme. Or, you could set the theme to Windows Classic and forget about trying to look snazzy.

Desktop Wallpaper

Go visit Smashing Magazine and download a desktop wallpaper. They scour the web for amazing wallpapers so you don't have to. It doesn't matter what you pick as long as it isn't the default 'blissful hill'.

Internet:


Browsers

As a web developer, I install every browser, but only really use Firefox. Opera 9 seems comparable, but it comes down to 1) extensions and 2) familiarity. Chrome isn't ready for consumer use yet, Internet Explorer 6 is a dinosaur, and Internet Explorer 7 is slow / annoying to use. I let Windows install IE7, and then install multiple IEs in order to get IE6. This lets Microsoft update IE7 for me, so I have the latest version for testing. Safari is fast, but I don't like the User Interface - it's too hard to find the features I am looking for (without even knowing if they exist).

Browser Plugins

Flash and Shockwave, Acrobat Reader, Quicktime (skip if you plan on installing iTunes), Java, Real Player or you can install Real Alternative which lets you play the RM files without the terrible media player!

Pidgin

Pidgin is an all-in-one Instant messenger. I like it for the custom smiley themes and plugins. I used to use Trillian, but it conflicted with my computer for some unknown reason. Astra looks awesome, but it's been coming soon for at least two years, probably more. Digsby looks kind of cool, and if Pidgin ever fails me, I'll try it out.

mIRC

mIRC is the best IRC client that I've tried. The UI is simple yet powerful. Lots of bells and whistles if you want them. And no fluff graphics either. I turn the theme to dark as soon as I install it.

Thunderbird

Thunderbird is better than Outlook Express. There might be a better free email client, but this one is good enough for me. I don't like the default theme, so I install Azerty Mail instead.

Azureus

Azureus (or Vuze) is a pretty good P2P app. Vuze sucks, change it back to the classic mode. Useful for downloading the latest Linux Distributions.

eMule

eMule is good for downloading old, hard to find programs.

LimeWire

Limewire is great for getting viruses and spyware!

AVG 8

Before installing Limewire, make sure you have some basic anti-virus protection. Unless someone out there knows of a better free anti-virus, I am currently recommending AVG-Free. Avira is also good, but has pop-up advertisements. Clamwin sucks, as does Avast.

Spybot S&D

Spybot's most useful feature is the teatimer system change monitor. This alerts you to changes to your registry, startup, browser, context menus, etc. Better than Vista's watch-dog because it actually tells you what is happening, and saying no lets the program continue to run as if it HAD made the change rather than just stopping the program from running altogether. I use this for programs like quicktime that want to add a startup entry so that it will load faster. Since I only use quicktime once every couple months, this is hardly a good use of my start-up space.

FileZilla

This is a great program, but I have not had good luck with version 3.x. I can only assume that it DOES work for most people or they would have fixed the issue already (disconnects every few minutes). If you can find version 2.x, it's pretty darn good.

Firefox Add-ons:


Camifox theme

There are a lot of good themes for Firefox, but Camifox is nice and simple without looking ugly.

Add to Search Bar

This lets you add any search box to the firefox search in the upper right-hand corner, instead of relying on the ten or so default ones.

Cookie Swap

Cookie Swap lets you quickly switch between named sets of cookies so that you can use multiple accounts with the same service without re-logging in all the time.

Edit Middle

An AwesomeBar hack.

Enter Selects

AwesomeBar Hack

Favicon Picker

Lets you change or add a favicon to any of your bookmarks.

Flash Block

Special mention to this extension for older computers that can't handle the amount of flash that some websites use. Or, if your eyes can't handle it!

Foxmarks

Useful if you have more than one computer, dual boot, or have ever lost all your bookmarks when your HD crashed. It synchronizes all of your bookmarks with their server, so that when you add a bookmark it is added to all of your computers.

Go Parent Folder

Lets you go to the parent folder after searching for a bookmark in the organizer.

Google Notebook

A notetaking thingy - there are some problems with it, but I haven't gotten around to trying any of the other similar extensions yet.

Google Toolbar

Essential for the 'Go to Next Search Word' buttons. I can't use the web without them.

Hide Unvisited

AwesomeBar Hack

HTML Validator

A Web Dev tool that tells me how many errors a web page has.

Old Location Bar

AwesomeBar hack - Tries to make the AwesomeBar just be a location bar, it isn't quite sufficient, and I'm not sure if it helps or hinders more ...

OpenBook

Lets you customize the add bookmark dialog.

Organize Status Bar

Firefox 3 didn't have the same status bar layout as FF2, this will let you move things around however you like.

ScribeFire

A quick blog editor.

Show Keywords

AwesomeBar Hack

Smart Bookmarks Bar

Transforms your bookmark bar into a list of single icons. This is where the favicon picker comes in handy.

Tagmarks

I haven't tried this one yet. It lets you add little icons to your bookmarks, visually placing them into categories for you.

Unsorted Bookmarks Folder Menu

This places your unsorted bookmarks in a folder that is accessible from the bookmarks menu.

Web Developer

By far the most useful extension that I have installed. It is the swiss army knife of web development tools.

Applications:


Open Office

Open Office is free and comparable to Microsoft Office. Writer is AWESOME! much better than Word for pretty much anything.

Google Earth



Edit Pad



Graphics and Design:


Paint.NET

Paint.NET is a free photo editor along the lines of Photoshop.

Picassa



Inkscape



Pepekura



SketchUp



Audio/Video:


CDex



Winamp



Streamripper

Streamripper rips individual songs from streamed internet radio stations. If you use the WinAmp version, make sure to get a custom skin for it, the default one is (was) terrible.

iTunes



Cool Edit replace



DivX



Step Voice Recorder



Video LAN



Switch Sound Converter



Tools:


Sequoia View



WinRar



TweakUI



For good measure, here's a list of the proprietary/non-free programs that I use:

Photoshop 7 or CS3
Flash
InDesign
Adobe Acrobat
Microsoft Publisher
Nero 6
FolioBound VIEWS (if anyone knows of a good replacement, leave me a note!)
PowerDVD (same for PowerDVD)

Saturday, October 11, 2008

AwesomeBar and Me - Why I've left Firefox.

I upgraded to Firefox 3 back when it was in beta. Then, I uninstalled and went back to Firefox 2. I tried it again a few weeks later. Then, I uninstalled and went back to Firefox 2.

This was quite a while ago, but I will explain how I felt at the time:

Something was lacking in Firefox 3 that made me uncomfortable, and unable to be productive. Namely, the address bar, which had been replaced with something called the AwesomeBar. My main beef with the AwesomeBar actually isn't its ugly look, or the fact that it retrieves bookmark results, but rather, the fact that it requires visual interaction to be used effectively. The address bar was reliable. I knew what it would do when I typed. Its algorithm was something that could be fully comprehended in my head. I knew if I had cleared my history before starting, and had gone to calendar.google.com once, then visited ubuntu.com and apple.com and microsoft.com that I could simply press Alt+D "c" down enter to go back to calendar.google.com. Furthermore, it was the same knowledge I used to operate the old Start->Run dialog back in Windows, and the same knowledge I use to operate every autocomplete field in every website and every dialog box in both Windows and Linux.

With the AwesomeBar, my absolute and complete knowledge of the data being searched was taken away. Sure, I know which types of things it searches, but I don't know what data was present (in page Titles, for example) The extra steps are that I would have to press Alt+D, type, then look at the results and determine if there was an error, if so, I would have to arrow to the desired result before pressing enter. The developers of Firefox knew this, that's why they redesigned the widget visually to try to create enough visual distinction so that it could be scanned quickly. The problem is, I don't want to visually scan it at all. That isn't something I have ever been accustomed to doing and it slows me down and takes my focus away from the page I was browsing.

Since that time, I have continued to use "good old" Firefox 2. However, for whatever reason, my Firefox 2 installation began to become unstable. It would freeze up requiring restarts quite often, usually when I click on a javascript-based link. I finally got irritated, and decided that maybe it would be time to update or switch.

First, I tried Crossover Chromium. It is goofy because of its dependence on wine. I will give it another chance when it has been ported natively to Linux.

I searched through the Firefox add-ons/extensions to see what has been created, and found both "oldbar" and "Old Location Bar" - I had tried oldbar before, so I decided to go with "Old Location Bar," bit the bullet, upgraded to Firefox 3, and installed the extension. I didn't read carefully enough, and I presumed Old Location Bar would do what I wanted, as people were praising it for being better than oldbar. I was disappointed with Old Location Bar. It still didn't solve my problem at all.

Firefox 2 is freezing up. Firefox 3 is not efficient. I decided to go "old school" and switch to Opera.

I installed Opera 9.27 from the Hardy repository. Just a little ugly feeling in the menus, but the toolbars are not too bad. I can live with this. Alt+D doesn't work! Dang. So, I did this:

Tools -> Preferences -> Shortcuts -> Keyboard setup - Opera Standard -> Edit.

The one under "Browser Window" that says "Focus address field | Focus message list" I clicked, and changed to "d alt", clicked OK, and clicked OK again. Alt+D ... works!

Now I did some experiments with the address bar. It works!

I realize I'm not using the latest release of Opera. I may try upgrading and see if it still works. But, as long as it does what I need, maybe this older release is fine.

As I save this post, regrettably, I will change my default browser to Opera and uninstall Firefox 3. It isn't because I wanted to. It's because I was forced out. If I knew how to fork the Firefox code and reinstall the genuine old Address Bar, I would rather do that.

Thursday, March 13, 2008

Desktop Diet!

A great presentation by Rasterman, the head coder of Enlightenment.



I tried out E17 the other day, and it's not as good as I hoped it would be. Ah well!

Monday, September 17, 2007

Linux Blog Online

I'd just like to tell everyone about this blog - it's informative, interesting and funny!

enjoy!