code snipit…

Monday, September 22nd, 2008

I was working on a project for a friend who wanted to use css styles on some product pages of theirs. They could not easily add the css as an external link, which resided on their own site (different from the site with the product pages). This would not be a problem except that they wanted their css to cover about 400 pages. As you can imagine that would make maintaining the pages much more difficult to maintain. After much head banging to try and get ajax and iframe solutions to work I came across a very cool trick.

Just create a javascript function that inserts a link tag pointing to your external css. This worked like a charm in IE6, IE7 and FF3.

function loadCSS(loc) {
var
headID = document.getElementsByTagName(“head”)[0];
var
cssNode = document.createElement(‘link’);
cssNode
.type = ‘text/css’;
cssNode
.rel = ‘stylesheet’;
cssNode
.href = loc;
cssNode
.media = ‘screen’;
headID
.appendChild(cssNode);
}

<span class="pun">loadCSS("http://example.com/external.css");

</span>

The obvious drawback to this approach is that if someone has javascript turned off then none of your css will show up. But in this case the site relied on javascript a lot. If you are interested in more information on this and other cool tricks you can read more here.

i finished a book…

Wednesday, September 3rd, 2008

I recently finished a great book called “10 Books That Screwed Up the World: And 5 Others That Didn’t Help” by Benjamin Wiker. It was a very insightful look into the history of modern thought. It was also eye opening to to see how embedded this is in my own thinking. I was struck by the fact that at the heart of each of these books was the rejection of God. Atheism is the foundation of such current thoughts as relativism and a foundation off of which many of the atrocities of the 20th century have occurred.

This book is from the point of view of a Christian, however, I would suggest this as a read for any person as it does deliver well thought out critiques of these books. And then read the books to see for yourself if you agree with Wiker’s critique.

hotel misery

Sunday, August 31st, 2008

So we were at a hotel this weekend for a wedding. It was a very nice hotel. Much nicer then ones that I usually stay at. We were able to snag it on priceline.com for a great price. The only problem it seems is that some of the other guests felt that it was ok to have a loud party in their hotel room at midnight. It was pretty inconsiderate really.

As I consider the situation I realize that many times I am like these guests. I assume that since I have the ability to do something then I have the right to do it. I overlook the consequences and effects of others. It is very difficult to consider the other person because this implies a sense of social responsiblity towards others. But beyond that it means loving your neighbor.

Bananas are evil

Tuesday, August 19th, 2008

I recently read an article about the history of the Banana industry and all unfair practices that went on and still go on today. The article then made mention to Fair Trade. I have heard a little about Fair Trade from my coffee loving brother but never really looked into it.

Fair Trade — what is it?

From what I can tell Fair Trade is the idea of giving producers of developing countries a fair price for their product which causes a stable low end price and results in sustainable production.

So if a farmer has X amount of costs associated with getting their product to market. Negotiations with suppliers begin at this X price guaranteeing that the farmer always brakes even. This premium is past on to the consumer in the form of a higher price. It is then marketed as added value of “ethical” or “social responsibility” buying.

I applaud Fair Trade as a concrete way of addressing poverty that is not just giving a handout. However, there are a few outstanding issues with this approach that come to my mind.

1. Keeping prices stable for farmers at their production costs allows them to provide unlimited production no matter the current condition of the market. This gives little incentive to innovate and could possibly flood the market with producers giving way to excess supply.

2. Many poor developing countries rely on just one or two exports or worse just work with one company to deliver their product to the world. This cuts down on getting the a fair price and puts producers at the mercy of the market’s volatile ups and downs.

3. It makes the consumer feel that they are subsidizing the producer to work at something that seems to be failing.

Another approach might be to focus on diversifying exports of these countries. It seems that many of these developing countries are dependent on only one or two exports for trade. Encouraging more diversity first domestically building their own economy. Then taking this diverse trade globally would lend to a stronger economy in the world market. Volatility in the global market would then have less of an effect because domestic trade could be a fallback. This allows the people to enjoy a stable price without putting an artificial premium on consumers.

Fair Trade is a good first step in trying to address issues of poverty in developing countries. More steps are needed to help these countries to succeed.

Blender meet up

Wednesday, August 13th, 2008

So I met someone that I came across on the internet. Usually I would never met someone from the internet unless I already know them in real life. You never know what crazy, wacky person you might find in this wild, wild web of ours. So why did I? I was trying to find a Blender user group in Atlanta (which apparently does not exist). I came across someone else who two years ago tried starting a group. It never came to anything but we did meet up to talk Blender.

I didn’t really know what to expect when we finally met up. After a few awkward moments we got into Blender. It was amazing all the things he knew. I definitely had information overload by the end of our converstation. I showed off the few small pieces that I worked on because being the geek that I am, I had brought my laptop with me. All in all it was a pretty good experience though I am sure by the end he was annoyed that I did really know anything. Will this be the start of an Atlanta Blender User Group?

blender mountians

Friday, August 8th, 2008

This past week I have been continuing with the blender book and created some landscapes. The few tutorials were about textures and it was fun to see my project evolve and take shape as I went along. It was also fun to see a finished render that was not just gray but had some color to it.

As I have been going through these tutorials I have been pretty surprised as to how simple it is to do 3d modeling.

Mountains with texture but no stenciling.

Mountains with texture but no stenciling.

Mountains after stenciling was applied...a bit more realistic.

Mountains after stenciling was applied...a bit more realistic.

I know that this is not very spectacular looking but I am pretty proud of it.

a new obsession…

Thursday, August 7th, 2008

I recently found out about a fun little game called Robocode. Now this is not a game for the non-programmer because you are coding a bot program with in the Robocode framework.

This takes me back to my college days when my university had a game called “battle bots.” Basically, you code a bot (a program) that runs in the main program along side other bots and they fight each other till one last bot is standing. The really cool thing was that there was no human intervention. So we would go into the computer labs and set up a big screen watching our creations battle it out.

Robocode is not as elaborate as the battle bots but it does give me an excuse to play with some AI techniques without having to write a whole custom environment. Maybe I can use Joone to develop a NN Robocode Bot.

I just got my Freeduino…

Wednesday, August 6th, 2008

I finally got my Bare Bones Arduino (aka Freeduino) from ModernDevice.com. I didnt realize how small it would be! It is super tiny. So now I guess I am going to have to learn how to use this. I wonder if there are any Arduino user groups in the Atlanta area. What I really need to know is what kind of cable this needs so I can start playing around with it.

neural nets

Monday, August 4th, 2008

From time to time my thoughts always go back to Artificial Intelligence type programming techniques. Neural nets are always so intriguing, its like a little black box. you put in your inputs and the program gives you what it thinks it should be with out having to actually program it in the traditional sense. My biggest problem is that I could never find a good open source program to be able to easily generate and program neural nets. That is until recently when I stumbled across a project called Joone. It is pretty well done NN engine and has a GUI interface to be able to test out NN ideas.

justforfun program…

Friday, August 1st, 2008

This is a fun little program copied from processing.org’s spore2 simulation. I want to use this as a base for an AI life experiment that I have thought about creating for a while. I want to investigate how physical shape and apperence can effect the interaction between creatures. For anyone interested in seeing my program you can run it from java web start. This program does not have a digital signature so your OS may complain about it. You can also download and browse the source.