Tuesday, December 7, 2010

2D Games with Kitten-Fu, Part Two

When we left off in part one, you should have had a kitten that skated across the screen forward and backward. This would be awesome for a hover ship, but let's animate our little cat so that its legs move while it is walking. (oh, I'm also using the KFu alpha 13 library now)

The Sprites


We're going to use a sprite sheet for our cat, so that means adding all of our cat's various poses to a single .png file. I'm going to limit myself to 16x16 for each of the kitten's poses, that way I don't have to keep track of what size I made what, and it helps with the retro look too. Kitten-Fu allows you to specify any size you choose, just make sure you keep good track of your sprites if you make them irregular.


You can see four poses of my cat here. The first is the original position from part one, the second is with the right legs extended, the third is with all four legs in the middle. I was purposely vague on which leg was in front for this middle pose so that I didn't need to draw a second center pose. The last position is with the left legs extended. It took me quite a while to get the animation correct. If you are drawing your own sprites, I would recommend that you get the basic shape you want, then code the animation sequence, and then fine tune it when you can see the changes in action. I used a couple of YouTube videos to help me get the leg shapes correct.

My first attempt at animating my cat was in the middle of the night while I was almost asleep. I'm including it here as an example of what not to do!


The Code


So far we've only been working with a KFu stamp, and we really haven't tapped its full potential at all. One of the cooler things a stamp is good for is making "slices". A slice is a piece of a stamp that is cut out and used as a sprite the same way we used the stamp in part one. What makes a slice special is that it doesn't take up more space in memory to use it. We can load one sprite sheet, and then cut multiple slices from it, creating a veritable cornucopia of sprites on the actual screen!

After we add the new kitten poses, we can leave our stamp code the same, but we're going to add our slice code underneath:

  slice kitt1stand(kitt1, 0, 0, 16, 16);

We'll also want to change where we put the kitt1 stamp to refer to the slice instead:

  kitt1stand.put(k1x, k1y);

Now we're going to use an array of slices for our animated kitten. An array is a way to give a list of items numbers rather than names--this can be quite handy as we will see in a moment. In this case, we're going to pre-load all four frames of our animation, and save them as slices.

  slice* kitt1walk[4];
kitt1walk[0] = new slice(kitt1, 16, 0, 16, 16);
kitt1walk[1] = new slice(kitt1, 32, 0, 16, 16);
kitt1walk[2] = new slice(kitt1, 48, 0, 16, 16);
kitt1walk[3] = new slice(kitt1, 32, 0, 16, 16);

You can see that for each slice above (for the animation and the first pose in kitt1stand) there are a couple different parts:

kitt1stand or kitt1walk[x] are both slice names that we use later to call them into use, and after that are our options in the parentheses. kitt1 refers to the stamp that we set up earlier on line 12 of part one. The series of numbers refer to the x-position and y-position (the top left corner of the slice), and the height and width of the slice. Of course the slices could overlap if we wanted them to, but for now that would make our cat look like a mutant.

We can't just replace kitt1stand with kitt1walk, otherwise our kitten would be animated even while it was standing still, so we need a way to tell if the cat is moving, and only show the animated slice array while that is true.

We already have a walkleft and a walkright variable that is set to true while the cat is moving, so we can just multi-purpose them! The way we're going to solve our animation problem for now is to set a counter that will rotate through the numbers 0-3 every x frames. We'll feed this number into the kitt1walk array and this will flip between all of the slices of the array in order. Add the following code right before you clear the display and begin painting. (and, don't forget to add any relevant variable declarations at the top of the program!)

  // ANIMATION //
if (framecount%8 == 0) {
++anim4;
if (anim4 >= 4) {
anim4 = 0;
}
}

Then, to make the counter tick, add the following to increment the frame counter every time through the game loop (I added it directly underneath the GAME LOGIC heading.)

  ++framecount;

We can re-use this counter for anything that we want to also run with four frames, as long as we don't mind that it is running in tandem with our cat.

Now that we've set up our animation, let's get it painted to the screen. Add a /// PAINTING /// heading underneath the animation code, and let's add some if statements around where we put kitt1stand. Basically, if walkleft or walkright equal 1, then we display kitt1walk, otherwise we display kitt1stand. I could write out the code for this a little more compactly than I have it below, but since we are about to add flipping, this sets up our statement nicely for that:

  if (walkleft == 1) {
kitt1walk[anim4]->put(k1x, k1y);
} else if (walkright == 1) {
kitt1walk[anim4]->put(k1x, k1y);
} else {
kitt1stand.put(k1x, k1y);
}

If you make your program at this point, you'll notice that the cat, although animated, moves way too fast (even for a ninja cat.) We need a way to slow that kitten down. How about a throttle on the game process? every x frames, we will register a movement. If we were working with smaller pixels, this would be less of a problem, but when your cat moves at 30 pixels per second, and your screen is only 128 pixels across ...

In the GAME LOGIC section, underneath the frame counter, let's stick our movement controls into a throttle of sorts:

  if (framecount%2 == 0) {

Now when you make the file, the cat walks slower but, especially if you're on an older / slower computer, you'll notice that the cat fluctuates in speed depending on your CPU usage. That's because I forgot that we need to use KFu's FPS thingy. To set it up, we need to add the following lines to the top of our actual game code, right after we finish declaring our variables and slices.

  fps framerate(1000/30);
framerate.start();

Then, at the bottom, right before we flip to the screen, add the following:

  framerate.delay();

we could have named framerate anything, and set the speed to anything we wanted. I can imagine that you could change this number for underwater scenes, or something like that.


Everything should work now except for the fact that your cat can only face one direction! Let's fix that (although, the moonwalking kitten is pretty cool.)

KFu already has options set up to allow for flipping, all we need to do is activate them. First, we need to create a flipped "instance" of our stamp. This creates a complete copy of the stamp in the memory, so don't flip or rotate more than you'll actually need for your program.

Your new stamp declaration should look like this:

  stamp kitt1("kitten1.png", KFU_LOAD_FLIPH | KFU_LOAD_NORMAL);

FLIPH is for flip horizontal, and then NORMAL is so you can load the regular file. If you don't declare any positional variations, KFu assumes you only wanted NORMAL, but as soon as you start declaring variations, you have to tell it exactly what you want.

Do you remember where we made our if statement a bit long winded for our cat animation? Change your slice code to the following for when the cat is walking right:

    kitt1walk[anim4]->put(k1x, k1y, KFU_PUT_FLIPH);

Now, the only remaining 'error' is when your cat stops walking, it always faces left ... Using a variable on the key presses, see if you can flip kitt1stand to face the correct direction after he finishes walking. I have a solution in the code included at the bottom of the post--see if you can figure it out without looking.

So, I lied about showing you how to add another cat, that will have to wait until part three. We'll create a kitten object, and work on the logic that will make kitten-2 follow kitten-1, as well as some grass for them to walk on.

The Files


You can download everything from part 2 here: kittens-02.tar.gz

* * *

Friday, December 3, 2010

2D Games with Kitten-Fu, Part One

As part of the UVOG arcade project, Jeff has been working on a 2d graphics library for C++ called Kitten-Fu. It's cute and fuzzy like a kitten but powerful like a ninja ...

I'm going to be using Kitten-Fu (KFu) and other open software to create a retro, side-scrolling game about ... what else, ninja cats.

As a way of introduction, I am a novice programmer who has dabbled in PHP and AVR Assembler. I'm going to be blogging my very first C++ program during this series.

First, we need to install the KFu library. KFu has a couple of dependencies, so make sure you install them first:

$ sudo apt-get install build-essential libsdl1.2debian libsdl1.2-dev libsdl-image1.2 libsdl-image1.2-dev

Once you have that, go to the Kitten-Fu wiki page and download the latest version of the library. I'm going to be using KFu alpha 10 to start with. After you have the file downloaded, extract it and in a terminal, navigate to the extracted files and type:

$ sudo make install

Now we have access to the KFu C++ libraries and can use them in our program.

Now, let's create a folder for our program to live in, for example: /home/yourName/Programing/kittens

The Sprites


I already know that I want my program to involve cats, and since I'm better at drawing than coding at this point, I'm going to start by drawing a sprite and then worry about getting it to the screen. For sprite creation, I use a program called MTPaint which is a great pixel editor. You can use any graphics program you like.

I drew my first cat at 16 by 16 pixels and in 4 colors, one of which (black) will end up transparent. I saved my sprite as an 8bit .png, which is an indexed file format - perfect for making a retro game. You could also use a 24bit .png which has alpha transparency (various shades of transparent) which lets you have pretty, smooth and curvy edges all at once! Make sure to let the file know that you want the first color to be transparent. In MTPaint this is through the save dialog. Here's a screenshot of my final kitty:




The Code


Okay now let's create our program files. I like to work with Nano, a command line text editor. You should use whichever program you are comfortable with as long as it's a text editor and not a word processor. (ie, not Open Office Writer or AbiWord, but using Kate or Gedit is fine)

In my kittens folder, I create a new file titled kittens.cc with the following contents:

// kittens
#include <unistd.h>
#include "KFu/KFu.h"
using namespace kfu;


This tells me the name of my new program, and that I want to use the KFu library. Save the file and then create another empty file named Makefile. A makefile is a type of script file so that you don't have to type out the compile instructions every time:

all: kittens_norun

kittens_norun: kittens.cc
 g++ -o kittens kittens.cc -lKFu -Wall --pedantic

kittens: kittens_norun
 ./kittens

IMPORTANT: The spaces on lines 4 and 7 are really tabs, make sure you replace them in your code.

Okay, save that, and now let's get that sprite to the screen! Open kittens.cc and add this to your file:

int main(int argc, char* argv[]) {
screen display(128, 120, 640, 480);
stamp kitt1("kitten1.png");

kitt1.put(100, 100);
display.flip();

sleep(5);
}

Before we talk about what everything does, let's make sure it works:

$ make kittens

A smallish black screen should pop up and have a little cat standing in the middle of it, and then it should close after 5 seconds. If this didn't happen, look back over all your code, and double check that everything is correct. I do have the project files included at the bottom of this post if you need them.

So, let's take a look at the code we just added. int main(...) { ... } is the wrapper for our actual program. Pretty much everything we do will be included inside of it.

screen display(128, 120, 640, 480); This sets up the parameters of our game screen. The first two numbers are the width and height of the game window. The next two numbers are the width and height of the screen. The game space will expand and center in the available screen space. This lets you change the size of the pixels on the screen. With the setup that we're using, we'll have a fairly small screen, and the pixels will be magnified x4.

stamp kitt1("kitten1.png"); This line sets up our stamp, giving it a name (kitt1) and telling it which file to use.

That's it for the setup, now we get to actually place the kitten on the screen.

kitt1.put(100, 100); Here, we name our stamp, tell it to "put" it to the screen, and tell it the x and y coordinates.

display.flip() is what actually paints the sprites to the screen. Very important, don't leave this out!

The last thing we do is tell it to do nothing for 5 seconds (sleep(5);) and then it gets the the final } and closes our program.

There are two things we need to add to our "game" to make it a bit more functional: movement, and a way to close it when we want rather than only letting it last for 5 seconds. Both of these are going to involve key presses, so let's add those in!

In between the screen set up and where we actually paint the cat, let's add a section:

/// HANDLE EVENTS ///
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_ESCAPE: done = 1; break;
default: break;
}
break;
}
}

This basically says, look at all the keys that are down, if you see the escape key get pressed, then done equals 1 and then skip to the end of this section.

You will also need to add the following line to the top of your program, right after int main() { in order to access the SDL event handling.

SDL_Event event;

Now, we need to tell the program that it should should skip on down to the end of the entire program when we press escape.

So, surrounding everything but the first few lines of setup, add a while statement:

int main(int argc, char* argv[]) {
SDL_Event event;
screen display(128, 120, 640, 480);
stamp kitt1("kitten1.png");

while (!done) {
... your code ...
}
}

We're going to have to set up the variable at the very top of our program, in between main() and the SDL_Event line:

int done = 0;

Now, we can clean up our code by removing sleep(5); as well as #include <unistd.h> since we aren't using them any more.

I guess I should mention that you should be compiling and running your program in between each set of changes so that you see the progression as we go along.

So, let's make that kitten move! Add the following line underneath the escape key press:

case SDLK_LEFT: walkleft = 1; break;

This sets the walkleft variable to 1. Add the walkleft variable underneath the done variable:

int walkleft = 0;

All by itself, that doesn't do anything--we need to use that variable in an if statement in order to change the coordinates of our cat.

First, change kitt1.put(100, 100); to:

kitt1.put(k1x, k1y);


now, let's preset our kitten's coordinates to the bottom right of the screen by setting our variables:

int k1x = 110, k1y = 88;

Now all we have to do is create our if statement and place it right before we put the cat to the screen:

/// GAME LOGIC ///
if (walkleft == 1) {
k1x = (k1x - 1);
}

If you run the file now, you'll notice that the cat smears itself across the screen, we need a way to clear the screen each time we paint. So let's add the following right before we "put" our cat to the screen:

display.clearSurface();

Next, we need to get the kitten to stop moving after you let go of the left arrow. We need to add a whole section to our Handle Events section right after the break; for case SDL_KEYDOWN::

case SDL_KEYUP:
switch (event.key.keysym.sym) {
case SDLK_LEFT: walkleft = 0; break;
default: break;
}
break;

To get the kitten to wrap around to the other side, add the following tight after we decrement our x position:

if (k1x < -16) { k1x = 128; }

The numbers I chose here make sure that the kitten disappears off the screen before it re-appears on the other side.

You should be able to add all of the code to move the kitten to the right rather than just the left.

Next time we'll flip the kitten, animate it and add another kitten to follow it around!

The Files


You can download everything from part 1 here: kittens-01.tar.gz

* * *

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!

Friday, September 3, 2010

Robot Logic, Part 1

UVOG has decided to make a robot as a club project. It will consist of Open Hardware and Open Software, and be easy for people to make at home on the cheap by repeating our steps.
My specialty is the software. So far, we have decided to use a handful of ATtiny2313 chips to control the various appendages and modules of the robot. The ATtiny2313's will be hooked up to a root controller of a type that is yet to be determined. So, I'm going to be learning AVR assembler to program the ATtiny2313 chip, but for now, I've been doing my experimenting with C. Assembler actually looks easier to use in this case, since I am so interested in direct pin manipulations and our memory space is so limited (2k program memory plus 256 bytes of SRAM and 256 bytes of EEPROM.)

One of my eventual goals is to learn the self-programming functions of the AVR instruction set so that I can reprogram any chip in the robot in place without any additional wiring other than that which we are using to send instructions from the root controller to the sub-controllers, but for now (until I have taught the chip how to do this), I have to use an external programmer.

Programming the Microcontroller

I've used three different programming boards for the 2313 so far. The first one was a hand-made parallel port programmer, which pulled its current from a USB connector. The second one is a board from Evil Mad Scientist which connects to the PC entirely with USB, through an adapter. Both of these were ok, except I kept having to pull the IC from the programming board, and put it on my breadboard for testing, then after failing (it is inevitable), pulling it again and returning it to the programming board. The third programmer is also a hand-made one, but this time it has two female headers running the length of the chip that I can plug test wires into. It also has a six-pin connector to attach or detach the parallel cable, which is a lot easier than running around behind the computer every time.

My debugging process now looks like this:

Plug the IC into the programming board. Plug the USB and Parallel into the PC, and plug the other end of the Parallel into the programming board. I will leave the IC , the USB and the Parallel (on the PC side) plugged in the entire time I'm working. The only cable I will unplug during the debug process is the programming board side of the parallel cable.

So far, I have not been using the UCSK, MISO, MOSI, or RESET pins (a.k.a., pins 1, 17, 18, or 19) in my actual experiment, so I can leave the IC on the test board, and hook up my other components by jumping a wire from the headers to the breadboard.

I unplug the single wire going from GND (pin 10) to the breadboard's ground bus, and I plug in the six-pin parallel connector, then run "make", and my toolchain compiles and automatically uploads the compiled code into the chip. Next, I plug the wire from pin the breadboard's ground bus back into pin 10 (GND) on the header, and I unplug the six pin connector, which releases the RESET pin causing the chip to boot up and run my code.

When I want to test again, I simply unplug GND and plug the six pins back in.

If I simply need to reset the chip to test the boot sequence again without reprogramming it, I can either apply a GND lead to the reset pin, or plug the 6-pin parallel connector in momentarily to accomplish the same thing.

How I Plan to Use the Chip

The 2313 has a nice amount of general purpose input/output pins. They have given names to the pins to indicate how they are treated internally as "ports." Along the "left side" of the chip, we have RESET (which doubles as PA2), then we have PD0, PD1, PA1, PA0, PD2, PD3, PD4, PD5, and GND. And going up the right side of the chip we have PD6, PB0 through 7, and VCC (our voltage source.)

For most of the chips in this project, I plan to use them in the following way:

Pin 1, 10, and 20 are keeping their purposes as RESET, GND, and VCC. Although repurposing RESET is possible, it is dangerous because it disables the programmability of the chip (RESET is normally held low while the chip is flashed.)

All the other pins down the left side are going to be used as inputs, in addition to pin 11 (the bottom pin on the right side.) This gives us a total of nine input pins which are known internally as PORTA and PORTD (with the exception of PORTA bit 2, which is reset.) When used as inputs, the values are actually read from the ports called PINA and PIND. All of the remaining pins on the right side will be used for outputs, which is known internally as PORTB.

Quick Review:
Input: 2 bits of PORTA and all 7 bits of PORTD. (actually PINA and PIND)
Output: All 8 bits of PORTB.

Some of our inputs have special functionality that we will be interested in, so we need to be careful to reserve those for the purposes we intend to use. Specifically, pin 6 and 7, a.k.a., PORTD2 and PORTD3 are the lines used to raise INT0 and INT1. INT0 is interesting to us, because it is the only regular user-definable interrupt that can raise the micro-controller out of its power-saver or sleep condition. (I don't remember exactly the term used for this particular sleep mode at the moment.)

I plan to use INT0 and INT1 to "talk to the chip" from the root controller.

This leaves us with the following general purpose inputs, which I would tend to utilize in the following manner:

Most Significant - - - - - Least Significant
PD6, PD5, PD4, PA1, PA0, PD1, PD0

If I care to get this into a single byte (sans the high bit), I think I can do so by performing the following bitwise operation:

MyInput = ((PIND & 0x73) | ((PINA & 0x03) <<>

Because the ATtiny2313 uses internal pull-up resistors, the default state of all the pins will read as high values (1). To toggle a pin, we must apply ground to it, which will lower it to zero. In other words, when we are dealing with inputs, "low means active." We might, therefore, want to inverse the value of all bits of input, so that we can logically use 1 to indicate active and 0 to indicate inactive.

Gotta run, I will post more on this later.

Thursday, August 19, 2010

Support for older Intel Graphics Chipsets in Lucid Lynx

For those having trouble getting Intel Brookdale G [82845G/GL] and similar chipsets to work on Ubuntu 10.04, I have good news. The Ubuntu Wiki has a page containing workarounds and fixes for the issue. My preferred choice right now is to install the backported Maverick kernel. This is also good news, because Ubuntu 10.10 should be expected to work on these machines without adjustment. Of course, if you just want the system to work with basic office-style functionality, VESA mode is a good alternative, but it will disable accelerated video.

Thursday, August 12, 2010

Tuesday, August 3, 2010

Tutorial on making colored maps

This Tutorial uses a Python script and free SVG maps to make maps based on csv data files! I know what I'm going to be doing tonight when I get off work!

How to make a US county thematic map using free tools [flowingdata.com]



Edit:
Michael made his own version of the same map following the tutorial! Here it is:



Video, State of Free Software

Listen to this video of Eben Moglen's presentation on the State of Free Software.

Monday, August 2, 2010

Oregon's E-Cycle program flawed

We are required by law to print the following three lines on receipts for purchases of new computers or monitors, or to distribute one of several graphical alternatives:

Oregon E-Cycles: Free Recycling
for Computers, Monitors and TVs
www.oregonecycles.org 1-888-5-ECYCLE

Unfortunately, the Oregon E-Cycles program is seriously flawed and could hurt the freedom of the economy and the freedom of choice of consumers. Don't get me wrong. I support and encourage recycling and care for the environment, but this law over-reaches its purpose. The e-cycle website states: "Only those brands listed as pending or compliant may be sold in or into Oregon. If a brand is not listed, it may not be sold. Sales restrictions apply to all types of sales including retail, catalog, phone and Internet sales."

The DEQ decides the fee that a particular manufacturer must pay to register. If they don't pay up, they aren't allowed to sell their product [legally] in Oregon. DEQ determines the fee based on statistical information which they acquire in order to determine the market share held by the brand in question. They start with national statistics and adjust it based on a limited amount of local statistics. The minimum fee right now is $40. If a brand has more than 0.01% market share based upon DEQ's manipulated statistics, the fee goes up to $200. For brands with more than 1%, the fee is $15,000, which is the amount they are apparently collecting from prominent national manufacturers such as Dell and HP-Compaq.

Imagine if every state implemented an identical program. Dell would have to pay three quarters of a million dollars every year just to be an authorized manufacturer, and that money does not go towards recycling. The manufacturers pay for the recycling fees themselves. A little shop that assembles generic computers would have to pay a combined $2000 to all fifty states, which might be more than they make in computer sales during the year, especially if new computer sales is not their main line of business.

This is, of course, a bad scenario. It is unlikely that all fifty states would demand payment from a vendor. The states would have to become aware of that brand being imported into their state before they would likely make such a demand, and even so, is it enforceable if another state demands that you pay them a fee just because someone carried your product across state lines?

Also, what's to say that a particular state can't raise the rates or file you in a higher market-share tier in order to pressure you out of the business. If I was a vendor in another state, and Oregon DEQ contacted me, I would be tempted to simply disable shipping to Oregon on my website, and place a warning label on my packaging saying that the product may not be imported into Oregon by the original owner--that's right! Used and refurbished equipment is exempt from the program.

Here's the bad part of the law: Oregon is shooting itself in the foot because it is trying to force manufacturers around the world to comply with its fees, which could reduce the choice that customers living in Oregon have on what they may purchase. Someone will have to set up a company just across the border that will purchase a new computer for you from a non-compliant manufacturer, then resell it to you as used equipment.

Frankly, I shouldn't have to pay fees to any other states, and other companies shouldn't have to pay fees to my state. No taxation without representation! If the states want to have purchasers pay fees because they purchased a computer or monitor, then the state should include this on the tax forms for their own residents.

Now, from the retailer point of view. Other than my purchasing options being limited by a list of brands put out by DEQ, which is quite disturbing, I also notice that I had the choice of using the three lines shown above on my receipts, or including one of the other printed materials of which there is a wide variety. The problem? All the materials are in color, and the section on logos specifically says that if you need alternate format logos including B&W that you must contact DEQ manually to request it. Why would a recycle program require me to print in color? They must want me to recycle my cyan and yellow toner cartridges on my laser printer more often. Well, I opted for the three lines instead to conserve toner, and to avoid showing the logo of this program which I detest.

Think about how much time and money is wasted handling all the extra paperwork, calculating annual market share reports, and certifying manufacturers. This process needs to stop.

If you too find this law to be over-reaching and limiting of your freedom, or believe that it does not serve the interests of recycling or caring for the environment, please contact your state senators and let them know that the flaws of this program need to be exposed so that action may begin to correct it and implement proper recycling legislation in its place.

Tuesday, July 27, 2010

Response to .DOC Attachment

What do you do when you receive an email file attachment in Microsoft's .DOC format? Sure, we could open it in OpenOffice.org and go about our business, but there's no guarantee that this will remain true for future versions of .DOC. Use of proprietary formats are a danger to interoperability and to future innovation. One good thing to do is to reply to the email and explain why they should send the attachment in a standard format. I've seen several canned email responses in the past, but most are too brief to explain the issue, or too harsh in their wording to satisfy my tastes. I was prompted to write a response after receiving such an email attachment today, and I have combined some of the best ideas from elsewhere and added some of my own. Here is what I would recommend:
The document you have sent was not saved in an accepted format for Internet mail.

It was saved in a proprietary format that is unreadable on several types of computers because the method for decoding the document is kept secret by Microsoft and is purposefully changed with each new release of Microsoft Word so that existing users of Microsoft Word will be forced to pay for expensive upgrades in order to continue to read Word Documents sent by others. For example, in 2010, Microsoft Office Home & Business 2010 was priced at $279.99, and Microsoft Office Professional 2010 was priced at $499.99.

Recent versions of Word have started using a newer, patented OOXML format. In many countries, it is actually illegal for other products to decipher this format. This is a lock-in technique used by Microsoft to maintain their monopoly on Office software, and by extension, their monopoly on the operating system market, since they have not released a cross-platform version of Microsoft Office compatible with other operating systems.

In most cases, the size of the file saved in Microsoft's secret, proprietary format is also substantially larger than a standards compliant file containing the same information and the same formatting.

It is also important to note that Microsoft Word documents are often infected with viruses. Excel, Access, and Power Point files are also vulnerable to infection. This potential for infection is largely due to the Macro language and the "Visual Basic for Applications" language which are built into the format to provide powerful programming capabilities. While powerful, these features were not protected with proper security precautions, and the majority of users do not actually use these features or even know that they exist.

What to do instead:

If you continue to use Microsoft Word, please have the courtesy to “Save As” one of the following formats: ODT (if available), DOS Text, HTML, or Portable Document Format (PDF) and after saving, send the resulting file as an attachment.

Alternatively, you could use a product such as AbiWord, KOffice, Google Docs, NeoOffice, or OpenOffice.org that allows you to save your document in the Open Document Text Format (ODT), which is an ISO/IEC International Standard, and is supported by such notable companies as Apple, Adobe, Google, IBM, Intel, Nokia, Novell, and Sun Microsystems. If you don't have one of these programs, I would recommend OpenOffice.org, which may be downloaded free of charge and used for any purpose, personal or commercial.

A third option is to simply type your message directly into mail (instead of typing into Microsoft Outlook or Microsoft Word) so that you won't need to use an attachment at all.

In the highly unlikely event that your document cannot be converted to an open, non-proprietary format, consider printing it and mailing it by post, or scanning it, and sending it in a standard graphic format such as PNG or JPG.

Thank you.

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.

ACNG Client side perl script part two

Please refer to these previous articles : Setting up ACNG ACNG client side perl script for set up and scripting Apt-Cacher-NG.


I have made some modifications to the perl script to allow for simple gui integration.
Props to @gpled for showing me zenity a couple of months ago.

Change this:
#!usr/bin/perl -w
#script by @robots_unix

{
print "Are you at CCC?";
$name = ;
chomp ($name);
if ($name eq "yes"){

To this:

#!usr/bin/perl -w
#script by @robots_unix
system('zenity --title "Apt-Cacher-NG" --text "Are you at CCC?" --list --radiolist --column "ACNG" --column "Toggle" False no True yes> aptyesno');

{
open(APT, "Location of aptyesno");
$name = ;
if ($name eq "yes\n"){


Then right-click on gnome-panel, click add to panel, click create custom application launcher, then for the command type: sudo perl location of your perl script.

Now you can change the hosts file by just clicking an icon on your gnome-panel.

Have fun.

Monday, July 12, 2010

Moving the close, minimize and maximize to the right side again

I just installed Wubi and Ubuntu 10.04 and love it!!
But I was used to the close buttons being on the right

type in the terminal
gconftool-2 --set /apps/metacity/general/button_layout --type string menu:minimize,maximize,close

you can also change it manually:

just type in terminal:
gconf-editor

then open apps -> metacity -> general
and change button layout on the right side to:
menu:minimize,maximize,close

I hope that is helpful

Linux Chrome fix backspace as back button

I like to be able to go back when browsing without using my mouse. I have found an extension which fixes the backspace so that it now goes back.

Install the extension:

Then click the radio button:
Activate Backspace for navigation in history object

And hit save. That is all.

Speeding up your Updates with Ubuntu and APT Cacher NG

If you are in a building with more than one computer running Ubuntu, you may have wondered why everyone has to download updates separately. The answer is, they don't. Here's how to accomplish it with a tool called apt-cacher-ng.

apt-cacher-ng is a fork of a project called apt-cacher, which in turn is an alternative to apt-proxy which is poorly maintained and upon my testing, was unreliable.

Setting up the APT Cacher Server

Begin by installing apt-cacher-ng from Synaptic Package Manager, or from the Terminal with the following command:

sudo apt-get install apt-cacher-ng

By default, the version of apt-cacher included with Ubuntu does not currently include security updates. We can easily add the security updates in, however, by following these steps:

As root, create a new file called /etc/apt-cacher-ng/ubuntu_security

sudo nano /etc/apt-cacher-ng/ubuntu-security

This file will be a list of mirrors from which the updates may be downloaded. We only want to insert a single line, the location of Ubuntu's official security updates server:

http://security.ubuntu.com/ubuntu

Save and close the file.

Next, edit the file /etc/apt-cacher-ng/acng.conf

sudo nano /etc/apt-cacher-ng/acng.conf

While we're here, you will see a couple of lines like this:

# Set to 9999 to emulate apt-proxy
Port:3142

I recommend that you follow the instructions and set the port to 9999 to emulate apt-proxy. Not only will this make your server compatible with systems expecting an apt-proxy server, but it will also make the port number easier for you to remember.

Next, look for this section:

# Repository remapping. See manual for details.
# In this example, backends file is generated during package installation.
Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol

We're going to add one more line at the end of this section to describe the Ubuntu Security repository that we are adding (make sure the following all goes on one line):

Remap-ubusec: file:ubuntu_security /ubuntu-security ; http://security.ubuntu.com/ubuntu

Now, save changes to this file and restart the apt-cacher-ng service.

sudo service apt-cacher-ng restart

If all went well, the server is now working. No you may proceed to setting up the clients. I strongly recommend making the server into a client of its own apt-cacher, as there is no reason for that system to download the updates from the Internet twice.

Setting up an APT Cacher Client

The basic idea of how to set up a client is to change all the lines in /etc/apt/sources.list to point at the local apt-cacher-ng server instead of at the internet servers. I recommend taking an additional step first so that you can easily flex between different servers. We will create a hostname alias called "apt-cacher" that points at your apt-cacher-ng server so you can simply re-point the hostname whenever you want to switch servers.

sudo nano /etc/hosts

We will add our own entry just after these two lines:

127.0.0.1 localhost
127.0.1.1 your-computer-name

If the apt-cacher-ng server is running on the same computer which you are setting up as a client, its IP address will be 127.0.0.1, otherwise, you need to find (or set) the static LAN IP address for your server. I will assume it is 192.168.1.10 in this example because that's what it is in our building here at CCC. The line you will add will look like this:

192.168.1.10 apt-cacher

Save and close the hosts file.

Now we will replace the entries in the sources.list to point at the cacher:

sudo nano /etc/apt/sources.list

The easiest way to handle this will be a search and replace.

First, replace every instance of "us.archive.ubuntu.com" with "apt-cacher:9999" (no quotes on either) If you are using nano, this is accomplished by pressing Ctrl+W, Ctrl+R, then entering the search string and pressing enter, then entering the string to replace it with, and pressing enter again, then when prompted, press "A" for all.

Next, replace every instance of "security.ubuntu.com/ubuntu" with "apt-cacher:9999/ubuntu-security" (no quotes on these, either.) If you are using nano, use the same steps as given above.

(In this example, we won't be handling the partner repository or any third party repositories which you might have installed.)

Save and close your sources.list. Your final sources.list if you are running Ubuntu 10.04 Lucid Lynx will look something like this:

# deb cdrom:[Ubuntu 10.04 LTS _Lucid Lynx_ - Release i386 (20100429)]/ lucid main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://apt-cacher:9999/ubuntu/ lucid main restricted
deb-src http://apt-cacher:9999/ubuntu/ lucid main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://apt-cacher:9999/ubuntu/ lucid-updates main restricted
deb-src http://apt-cacher:9999/ubuntu/ lucid-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://apt-cacher:9999/ubuntu/ lucid universe
deb-src http://apt-cacher:9999/ubuntu/ lucid universe
deb http://apt-cacher:9999/ubuntu/ lucid-updates universe
deb-src http://apt-cacher:9999/ubuntu/ lucid-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://apt-cacher:9999/ubuntu/ lucid multiverse
deb-src http://apt-cacher:9999/ubuntu/ lucid multiverse
deb http://apt-cacher:9999/ubuntu/ lucid-updates multiverse
deb-src http://apt-cacher:9999/ubuntu/ lucid-updates multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu lucid partner
# deb-src http://archive.canonical.com/ubuntu lucid partner

deb http://apt-cacher:9999/ubuntu-security lucid-security main restricted
deb-src http://apt-cacher:9999/ubuntu-security lucid-security main restricted
deb http://apt-cacher:9999/ubuntu-security lucid-security universe
deb-src http://apt-cacher:9999/ubuntu-security lucid-security universe
deb http://apt-cacher:9999/ubuntu-security lucid-security multiverse
deb-src http://apt-cacher:9999/ubuntu-security lucid-security multiverse

After you have have saved your sources.list, run the following command:

sudo apt-get update

This will download the package index from the apt-cacher server. You should see lots of "Get" "Hit" and "Ign" lines coming from http://apt-cacher (and other lines for partner and 3rd party servers) if everything is working right. Remember that the update command will still be running at the normal speed because it has to fetch the indexes from the Internet every time to determine if the cache needs to download any new files. Also, the first time a given package is downloaded will still be at normal speed, as well.

To try it out, run sudo apt-get upgrade to download any available updated packages, or just install a new package of your choice. The apt-cacher should be functioning from the command line tools, from Update Manager, and from Synaptic Package Manager. Just remember not to adjust your repository checkboxes under the "Ubunto Software" tab in Synaptic's Settings:Repositories menu, because it no longer knows which repositories we've enabled (they are visible, however, on the "Other Software" tab, and you may adjust them there.)


How To Switch Locations

If you are using a laptop or netbook, you may appreciate the ability to quickly switch from one loication to another, and even to be able to download updates when you are not near your regular apt-cacher-ng server at all.

I have come up with a strategy to accomplish this. All you need to do (and you must do this while your current apt-cacher-ng server is accessible), is repeat the above steps for "Setting up the APT Cacher Server" on your local machine, then you can simply edit your /etc/hosts file and change the entry for apt-cacher to point at 127.0.0.1 when you're on the run, or back to your server's IP when you are at home or work. Making that one line change will allow you to continue using all of the APT tools smoothly.

There is one disadvantage, especially for netbooks or devices with smaller hard drives, and that is that you will be storing two different caches on your hard drive for files which were downloaded while "on the go", one in the apt-cacher folder, and the other in the system's regular apt system cache under /var/cache/apt

Because of this, you may want to occasionally issue the command:

sudo apt-get clean

This will clean the system cache of installed packages out of /var/cache/apt, saving some disk space. This is generally a good idea to do on any Ubuntu system with disk space limitations, whether or not you are running apt-cacher-ng.

Also, if you ever need to delete the files under /var/cache/apt-cacher-ng, you may safely do so, and apt-cacher will download them again the next time they are needed.

Congratulations on successfully setting up apt-cacher-ng -- I hope! It has saved hours and hours of downloading here in our classroom.

Apt-Cacher-NG Client side perl script

First off a short explanation of Apt-Cacher-NG (acng) is in order. Based on a similar project simply called Apt-Cacher, acng is a download proxy for software packages, primarily for Debian/Ubuntu clients. (http://freshmeat.net/projects/acng/)
The way it works is the server at Community Computer Center, goes out to the official package and release servers and downloads the latest updates, that way when I, or anyone else wants to download updates, our computers simply have to download from the CCC server over the lan, which makes the download about ten times faster.

(Editorial Note: If you haven't set up apt-cacher-ng yet, follow this post first.)

The only downside is whenever I want to download the updates and I'm not at CCC, I have to go and edit the hosts file in /etc, so I wrote a perl script to cut down on the steps.

Copy the code into a text file and save it as a .pl, then to use, type sudo perl yourfile.pl.
While this is not the most elegant solution, it was my first attempt at using perl, enjoy.

#!usr/bin/perl -w
#script by @robots_unix

{
print "Are you at CCC?";
$name = ;
chomp ($name);
if ($name eq "yes"){ #When I'm at CCC
open(INFILE, '>/etc/hosts');
print INFILE "127.0.0.1 localhost
127.0.1.1 uname
apt-cacher_ip apt-cacher
#127.0.0.1 apt-cacher
apt-cacher_ip server name
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts\n";
close(INFILE);
}else{ #When I'm not at CCC
open(INFILE, '>/etc/hosts');
print INFILE "127.0.0.1 localhost
127.0.1.1 uname
#apt-cacher_ip apt-cacher
127.0.0.1 apt-cacher
apt-cacher_ip servername
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts\n";
close(INFILE);
}
}

Saturday, July 10, 2010

Mutt and gmail

I think gmail is cool but it could be quicker to use. Right now it is slow and if you use the html version it lacks shortcuts. I think the cool way to go is to install mutt and use it to read your mail from the terminal. This article talks about some of the reasons why it is nicer and some methods to use to make mutt notify you about new mail. And how you might be able to use gmail contacts inside mutt. I think it would be cool to use googlecl to grab a contact while in mutt.
install mutt with gmail through IMAP
I like the fact you can make your own shortcuts in mutt that go to certain folders that you have set up like gmail has.
the following will make it so you go to the inbox when typeing gi and others.
bind editor noop
macro index gi "=INBOX" "Go to inbox"
macro index ga "=[Gmail]/All Mail" "Go to all mail"
macro index gs "=[Gmail]/Sent Mail" "Go to Sent Mail"
macro index gd "=[Gmail]/Drafts" "Go to drafts"

all the rest of the options are listed in the link above. I like the fact that you can change the editor for mutt too.
and the wiki might be helpful
if anyone tries to install gmail or another client with mutt then post here and let us know how it went.


Friday, July 9, 2010

Too many messages in mutt

I have learned something useful for anyone that uses mutt to mail from the terminal. I can be used to get messages from cron that runs periodically. Cron can run as much as once a minute. My cron has been sending me the message "don't update" for 6 months. It has caused about 40MB or 29000 messages to pile up in mutt. Now I have fixed the problem so it won't echo out for success. It should only tell me about failures not successes since they don't happen very often.

Usually you can delete hundreds of messages by holding down the delete button but since I had so many messages I had to learn how to delete bult amounts of mutt mail all at once. Here is how to do it:
type D
This will tell mutt to delete using a certain pattern. I tried using "update" but it didn't work so I figured out what will tag all of the messages at once.
type .
Thats right, a period.
Then type $ to have mutt ask if you want to purge 29000 messages. It takes a second and its done.

Sunday, June 20, 2010

Using Exclamation marks in Google Command Line

As I found out in my previous post, you can't just add an ! into your post without getting a bash error. You can sort of escape them with a /, but then they both show up (like this: /!), which is silly. You can get around this by first, making sure that you use single quotes around your post and then adding a $ right before the quote that begins your post:

google blogger --title 'this is a blog post' $'this is an exciting blog!'

Saturday, June 19, 2010

Testing out the new Google CLI

Wow, Google keeps surprising me with new toys. I know I could just log into the GUI, but this is just too cool(bang)

Tuesday, June 1, 2010

Ubuntu 10.04 Lucid Lynx

We've had the chance to install Ubuntu 10.04 "Lucid Lynx" on several machines now. Except for one particular model of Dell, the experience has been wonderful. The boot time is great--less than 10 seconds on reasonably new hardware. The new default visual theme is refreshing and beautiful. It "just works," which is more than I can say for the aging Windows XP at this time, even when used with older hardware that it should "know about."

In fact, this release has been so good, that I've now reinstalled my personal notebook computer with a fresh copy of Lucid.

There are some downsides, such as the lack of customization in the login screen (a problem that has carried over from the previous release, Karmic Koala) but the trade off for speed and stability is well worth it, and I'm sure the missing options will be reintroduced in time.

For fun, I also tried installing Debian Squeeze, and was not as happy with the outcome. The Ubuntu team really does do a lot of work to make Linux more user-friendly. I also tried Linux Mint 9 Isadora, which is based off of Ubuntu Lucid Lynx, and it seems quite formidable in its own right.

Of note--I particularly like the inclusion of the new Thunderbird 3 email client. It has some amazing features, but its attempt to autodetect the settings for my mailbox was a failure, and I had to manually set the options the correct way--a task I don't think a normal user would have been able to do, since it involved turning off features that were turned on that in past versions of Thunderbird never were turned on. On the positive side, I love the new "Smart Folders" and the improved search capabilities.

Community Computer Center

Susie and I have opened a new business with an emphasis on Free Software. It is called the Community Computer Center, and is a "brick and mortar" store which sells GNU/Linux-based desktop and laptop computers, does computer repairs (including Linux conversions), and teaches a variety of classes from "introduction to computers" up to database design and programming.

We are also making Open Computing into our businesses' official blog, and its posts will be featured on the home page of our site, communitycomputercenter.com

Saturday, May 15, 2010

Working Video - Intel 82810 CGC, Lucid Lynx, emachines T1105, BenQ FP553

I had a lot of trouble with this video configuration:

I'm reviving an old emachines computer, model T1105. It has onboard Intel 82810 graphics, and I have it plugged into a BENQ 15" flat panel, model FP553.

I installed Ubuntu 10.04 Lucid Lynx, and as it boots up, I see something vaguely resembling a boot graphic (the words Ubuntu 10.04 centered on the screen with dots under it), then the screen flickers between black screen and a text console login prompt for a few seconds, until it finally leaves me at a login prompt.

After much struggling, and attempting to add a better PCI graphics, card, just to find out that the system became unstable with random reboots (probably because of the low wattage PSU in an emachine,) I reverted back to using the onboard card and attempted to solve the problem.

I installed all the latest updates using sudo apt-get update and sudo apt-get install to grab the kernel that was held back in the regular update. Still no good, then I generated an xorg.conf manually by doing this:

sudo Xorg -configure

It dumps the conf into your user's home directory as xorg.conf.new, so we copy it back like this

sudo cp ~/xorg.conf.new /etc/X11/xorg.conf

Then, I edited the xorg.conf:

sudo pico /etc/X11/xorg.conf

WARNING: Do not perform the below operation if you are using a CRT monitor. I am adjusting the refresh rates to radically different values, and it could harm a CRT monitor. This is only proven to work with the BENQ FP553.

I found the section labeled Monitor, which looks like this:

Section "Monitor"
#DisplaySize 310 230 # mm
Identifier "Monitor0"
VendorName "BNQ"
ModelName "Benq FP553"
HorizSync 50.0 - 54.0
VertRefresh 48.0 - 49.0
Option "DPMS"
EndSection

So that is the default for this monitor right now. I am pretty sure its wrong, because the vert refresh rate only allows a 1 hz variance between 48 and 49! Well, I decided to just open it up, by changing the HorizSync to 20.0 - 94.0 and the VertSync to 38.0 - 79.0, so my final section looks like this:

Section "Monitor"
#DisplaySize 310 230 # mm
Identifier "Monitor0"
VendorName "BNQ"
ModelName "Benq FP553"
HorizSync 20.0 - 94.0
VertRefresh 38.0 - 79.0
Option "DPMS"
EndSection

Saved my changes, ran sudo /etc/init.d/gdm start, and voila! It works.

There is a cleaner way. I should narrow it down to the correct specs. But i'm happy for now.