SLES / SLED 10 with Intel 965 Graphics

If you need to update your installation to work with Intel graphics, there is an RPM you can install that will likely resolve your issues:

http://download.opensuse.org/repositories/home:/mhopf:/hp/SLE_10/i586/intel-i810-xorg-x11-6.9.0.2-8.1.i586.rpm

Install that, then run Sax or edit xorg.conf, and make sure to pick the i810 driver. (This post is in response to the number of forum posts on this subject offering no solutions)

Tags: , , , ,

Creating a virtual machine using ubuntu-kvm-builder

I was playing with ubuntu-kvm-builder, and used apt-cacher for the mirror, and the build time is right around 2:30 which is pretty impressive. Using recordmydesktop I made a quick video of it, wanted to test the embedded video:

If you can’t see the video directly above this, you are not running a web browser that supports embedded videos (or you are seeing this on a planet).

Encrypted Swap

This post was spawned from my own misconception that my swap partition contained no sensitive data on systems with a lot of ram.

All of my systems I work with have atleast 4GB of ram, so my swap usage is usually under 2 megabytes. Why should I worry what’s in my swap partition?

Instead of going into it, just try it yourself. My swap partition is /dev/sda5. Run the command:

$ sudo strings /dev/sda5 | more

What came up was a ton of interesting data, from files I had looked at, print jobs, and bash scripts. So yes, even if you have enough ram, your swap is still very vulnerable to storing a lot of data about you.

Good news is Ubuntu 9.10 / Karmic will have the option to encrypt swap, which is on the wiki.

Tags: , ,

Manpages

Its almost the end of 2009, and I read on Planet Debian today a entry on writing man pages.

So man pages… where do we start? We have HTML / CSS / XML / RST which are all generally globally accepted formats of communication. Unfortunately, man pages do not use those.

And quite frankly, I am a fairly busy person, and have quite enough things to accomplish in a day. Why would I learn yet another formatting language? What justifies these files being in their own little world, when the whole world as a courtesy is supposed to provide them with their packages?

There really needs to be a movement to kill man pages in their current form, and bring them up to speed. A dialect for the sake of having a dialect really isn’t worth it when we have abundant alternatives.

Healthcare in the US

I am pretty sure nobody who reads my blog is against Obama’s healthcare plan, but if you are, we need to talk. (I know people outside the US might not understand to the extent at which this is a dividing issue here). Who would have though so much controversy would come from someone trying to provide everyone with healthcare? Not to mention someone who campaigned on the idea, and got elected in part because of it.

Lets get this real straight: This plan will save money. If you are against it, turn off Rush Limbaugh, Sean Hannity, and Glenn Beck, take down your confederate flag, and use your brain.

Today, anyone, healthcare or not, citizen or not, can walk into any hospital in the country and get treatment. Many people do. And the ones that don’t have healthcare? You and I pay for them, through our insurance, who receives inflated charges from the hospital because of the additional burden of these uninsured. Do you really think that having the government run healthcare is going to make us pay for everyone else more than we currently do? (For a point of reference every month I pay over $700 to insurance just for my daughter and I)

Having country-wide heathcare would allow us to formalize this process, and make sure that those who were previously going to the hospital and getting free care (ie defaulting on their payments) are now taxed for it. You can get out of hospital bills, but getting out of taxes is a million times harder. For people here illegally, that is a issue that is mutually exclusive from this, as their coverage wouldn’t change with this plan.

As for the idea of death panels? They exist already. Insurance companies drop people, and their personal savings run out. Sending a loved one to a nursing home or hospice is already deciding their fate. Before “ObamaCare” your fate was decided by money. After it, you will still be able to have to decided by money. That doesn’t change.

You can call it socialist, and I can call you a fool, because as I said already, we already care for everyone, they just default on their bills.

Go ahead and use the Post Office as a case study of why government shouldn’t run things. Show me one small business that can deliver mail to any address in the US for < 50 cents. It isn’t possible. What they do is phenomenal given their budget and scope. If I lived in rural Idaho, no commercial interest would ever drive a letter out to me for that price. And the benefits? Increased communication, resulting in increased national commerce. Driven anywhere? Yeah the government runs the roads so well I can do that.

Bring on your ignorance in the comments.

Tags: , ,

Xorg / X11 programming update

So I have been looking into Xorg development. I posted about it a few months ago, but little to no help came of asking where to start looking. After asking several places without any useful help, I actually found a great book:

However, in my haste to order that one, I ordered 2 of these:

So if you are looking to get started with X11 / Xlib / Xorg these are handy to have around. Since I have 2 copies of the pink reference manual, if you want one, email me at sharms at ubuntu period com and I will send you my extra copy for free. Or if you want I can bring it to Ohio Linux Fest 2009 and give it to you there.

Update: Book claimed already

Tags: , , , ,

Modern economics

I know I shouldn’t listen to talk radio, but I do, and I hear some of the dumbest ideas ever. The one I dislike the most is “If we print money it will cause rapid inflation!”.

Lets get this straight: Printing extra money will not cause inflation. The only time in which printing money causes inflation is when our manufacturing ability is at peak production. With the current situation of 20+ million being unemployed, we are nowhere close to peak production, and as such can ‘create’ money.

Obviously once those people are employed again and we get closer to peak production we need to be more conservative with the process.

That’s all.

Boring Friday – What are you doing that is fun?

Suffering from a little burnout after delivering a few projects. For those coders out there, what are you working on thats fun / exciting?

I will start:

Favicon_normalFollowing up from my previous post, the most fun thing I did was compete in the Engine Yard Contest.. I created a python client, which communicated the results back to my webserver every 23 minutes via xml. On the webserver itself, I used the watch command to provide stats that auto update: ‘watch -n 30 “cat /tmp/results | sort | uniq | head”‘. The results had their score first, with lowest being the best like golf.

My favorite webpage I have viewed today has been the Arch Linux July Screenshots thread: http://bbs.archlinux.org/viewtopic.php?id=75154

Tags: ,

Programming in C: Converting an Integer to Binary (int to bin)

Engineyard Competition
Recently I saw on some news site a competition to calculate SHA1 collisions. Naturally, I tried it out, but used Python, my preferred language. Unfortunately, my Python implementation was significantly slower than others using C (which was smoot since both C and Python implementations were completely dwarfed by CUDA implementations). I entered the competition after it was already in progress, and managed to get a pretty good score, but that was with an insane amount of computers crunching it.

So that leads me back to the topic of this post. Convinced that I had more hardware than anyone else in the competition, and that even though I started with less than 12 hours to beat everyone, I was pretty sure I should have won (before I saw the CUDA performance). So I started rewriting my hastily written Python program in C. The competition was already over, so this was purely for self improvement.

A Little Rusty
My first programming language was C, and I was an expert in it when I was 13 or so (probably 1992). Since then, my attention was driven towards Python and PHP, as the defacto languages of the web. This made me realize exactly how much I had forgotten about plain old C (my C++ was not horrible, atleast I could still understand C++ code written by decent programmers). Anyhow, part of the competition included taking numbers and comparing how much each of the 160 bits varied (ie 1011 and 1001 differ by 1 bit, 1100 and 1111 differ by 2 bits etc). So I wanted to make a C function that converts any arbitrary integer to a binary string (which really wasn’t the goal of the exercise, as the hashes were in hex, but it made me try and remember how to convert an integer as it had been so long).

Conclusion to a Very Boring Story
So I ended up writing an int2binary function and a program that converts them and prints them out. It will break with very large number, but I included a function to estimate it’s size (always going to the next number divisible by 4 as I like that padding), so linking that to a malloc would be trivial. I don’t suggest this is run anywhere as it hasn’t been really tested or code reviewed, but I like my answer better than most of the answers I found on the net, so I will share it with you, and hope to get a higher google score than the ones I don’t like:

int2bin.c

#include <stdio.h>

void int2binary(unsigned int n, char *buffer, unsigned int buffer_size);
unsigned int buffer_sizer(unsigned int n);

int main(int argc, char **argv)
{
        char buffer[2048];
        unsigned int binaryNumbers[9] = { 1, 4, 6, 8, 10, 55, 123, 2000, 2048 };
        unsigned int i = 0;

        for(i = 0; i < 9; i++)
        {
                int2binary(binaryNumbers[i], buffer, (buffer_sizer(binaryNumbers[i]) + 1));
                printf("%4u: %s\n", binaryNumbers[i], buffer);
        }

        return 0;
}

void int2binary(unsigned int n, char *buffer, unsigned int buffer_size)
{
        unsigned int i = (buffer_size - 1);
        buffer[i] = '\0';

        while(i > 0)
        {
                if(n & 0x01)
                {
                        buffer[--i] = '1';
                } else
                {
                        buffer[--i] = '0';
                }

                n >>= 1;
        }
}

unsigned int buffer_sizer(unsigned int n)
{
        unsigned int x = 1;
        unsigned int i = 0;
        unsigned int lastFound = 0;

        // Takes care of n = 0, and we dont need to loop for 1st case
        if(n < 16)
        {
                return 4;
        }

        while(1)
        {
                i++;
                if(n / x)
                {
                        lastFound = i;
                } else
                {
                        break;
                }

                x <<= 1;
        }

        // Not a multiple of 4, how much do we need to add to it
        if(lastFound % 4)
        {
                lastFound += (4 - (lastFound % 4));
        }

        return lastFound;
}

As you can see I did a pretty poor job commenting it and naming variables, basically though in int2binary we need to start from the right hand side and work our way left, so we start variable i at the end of the string and work our way back. We use & to compare variable n and 0×01 (which means that if the rightmost position has a 1, we add a 1 to the buffer, else add a 0 to the buffer).

For buffer sizer, this just tried to take a guess at how long that string should be. If the integer is less than 16 it will always be 4, so no need to do anything else (I was in recursive mode for a different algorithm so I was cutting things off at beginning mode). Otherwise we loop through, and try to divide variable n by variable x. Each time it is ran, variable x is shifted to the left, which has the effect of squaring the number. This is also super fast on the cpu.

For people not in C development mode, didn’t make a make file, but to compile it:

gcc int2bin.c

Output should be:

[sharms@sparrow ~]$ ./a.out
   1: 0001
   4: 0100
   6: 0110
   8: 1000
  10: 1010
  55: 00110111
 123: 01111011
2000: 011111010000
2048: 100000000000

Annoying people with code: A gentle introduction to C# and Mono Part 3: Creating a GUI (Graphical) Mono / C# Program

In this post we will cover how to make a basic GUI application using Mono along with Monodevelop. If you haven’t already, you will want to read part 1 and part 2 of this series before this article.

Monodevelop
Monodevelop is the tool we are using as our editor. This is Linux’s equivalent of Visual Studio. It can be used to code, debug and design your application, and can link in with revision control systems. This article was written using version 2.0, if your version is not 2.0 you may see slight differences.

Create your project
After starting Monodevelop, go to File -> New -> Solution. You will be presented with a prompt asking which kind of solution we are starting. Click on C# -> Gtk# 2.0 Project as shown below:

new-solution

Read the rest of this entry »

Tags: , , ,