Friday, December 5, 2008

Alternative to music DRM.

Lots of people don’t like DRM mainly because it’s a bad solution. A few problems with it are: that it is dependent on a central server that eventually shuts down, you lose the music if you change your computer, and you can’t make back up copies.

Most people say the best alternative is no DRM and sell music for cheap which is a lot better from the customers perspective but the music companies really don’t like it because there is no anti piracy methods and they think they will make less money.

An alternative implementation I have thought up is to create a new container for the music file. The container would hold the music and metadata and very detailed information about the user who bought the music online and it would be digitally signed with the private key of the publisher. The players for this format would refuse to play the music if it was not properly signed.

If the information is changed then it would not validate.

As far as the end user is concerned the file would play where ever they copy it too. And would but just like a non DRM file. Now you may ask “how does this stop piracy? If the music can be copied anywhere then it is no better then No DRM!”

It works differently then DRM because instead trying to stop people from making any copies it makes it easy to know exactly who is making illegal copies. If a music file is found being distributed online you know exactly who bought it and can easily go to court. After a while people would realize how easily they can be caught and stop putting music online or sharing it with friends. Also if a computer has a bunch of music on it, it would be easy to tell if they bought it or if it’s an illegal copy.

This solution requires no central server just the authorized player that has a list of authorized publishers. It is no where near perfect and is easier to circumvent then current DRM, but it has one major advantage over DRM: it does not harm legitimate users. People who follow the law would have no desire to circumvent it, only people who want to pirate it. Only scenario where legitimate users would want to circumvent it would be to play music on some device that does not have an authorized player for it.


This kind of DRM can be easily applied to movies and computer games. It could actually be more effective on computer games then on music.

Monday, December 1, 2008

Fast Persistent Data Storage Idea

There are several types of data storage technologies out there. The hard drive is cheap but slow seek speeds kills it when random access occurs, and a physical impact can literally kill it. Flash memory is faster then a hard drive and can withstand physical impacts but it has a limited lifetime do to the number of writes it can take. Random access memory like ddr3 is even faster then the flash memory and does not have lifetime issues, but is volatile meaning it looses its data when it loses power.

A while ago I thought of an idea on how to have the speed of ram but have it persist like flash. Its rather simple really, just combine on a single chip or board a equal amount of ram and flash and a capacitor to power the ram long enough to write the rams contents to the flash.

So this is how it would work:

When powering up the device (ram, flash, capacitor, and controller) would copy the contents of the flash over to the ram and charge the capacitors.

Until the capacitors are fully charged access to the drive would be denied.

When the device is accessed all reading and writing is done to the ram.

When the device looses power it copies the Rams data over to the flash. (Could add logic to only copy what has changed.)

This increases costs quite a bit but it gets rid of all the weaknesses of known storage technologies. It will be shock resistant, fast, long lasting, and its data persistent.

Porting Mono's SslStream to SilverLight

I have recently run into another problem with Microsoft’s stripping of the silverlight runtime. This time I was looking into using Sockets, because of the crippled WCF implementation. But sockets have been badly stripped. The only thing in the System.Net.Sockets namespace is the Socket class. No TcpClient no UdpClient and no NetworkStream. The System.Net.Security namespace is also gone. Meaning no SslStream.

With no SslStream and a sorely lacking implementation of WCF, silverlight is pretty insecure. Not in the fashion of a computer virus but in how FTP transmits passwords in clear text.

I’m not sure what kind of applications Microsoft expects people to write without being able send files larger then a few megabytes with WCF or to secure their Socket’s data with an SslStream. I’m starting to think Microsoft made a very bad mistake with trying to shrink the runtime so much. I bet people will either write insecure applications and blame silverlight or avoid it all together. Deep market penetration caused by a small download will mean nothing if developers don’t write programs for silverlight.

Anyways that’s enough complaining about the free framework that Microsoft spent a lot of money to write.

A rather simple yet time consuming solution to this issue is to port Mono’s implementation of .Net APIs that are needed. I’m not sure how much effort will be needed, but it should be rather simple to do. Write access to Mono’s repository would be required keep it synced with Mono so that’s not something I can do. Basically you would just sprinkle some compiler directives to exclude classes and methods that are not possible. Also add extension methods to extend silverlight classes that don’t have needed methods. Then write build scripts that compile those for silverlight. For limited subset of classes like the NetworkStream it should be relatively easy to port them to silverlight. Classes like the SslStream will require more effort because of its reliance on Certificate stores.

Wednesday, November 19, 2008

My Solution to the Pirates

Currently there has been a large amount of talk about the Somali pirates. The solution to this problem is rather simple. No it’s not sending in the US Navy. No in this scenario my solution is much simpler. Let capitalism have a whack at it. Some mercenary company needs to sell their services to the companies that own these ships for escort duty. Comparing to what I assume and multi-million dollar ransom demands hiring an army of mercenaries would be small in comparison.

Friday, November 14, 2008

A Dynamic SilverLight DataGrid.


Note: this article is about how to set the values for the DataGrid. If you want to see how to add columns dynamically check out this article: http://blogs.msdn.com/scmorris/archive/2008/04/14/defining-silverlight-datagrid-columns-at-runtime.aspx

I’ve recently come across 3 very annoying limitations in Silverlight 2.0 while trying to use the data grid. The first is that the DataTable class does not exist. This is the typical way to set the ItemSource for other .Net DataGrid/GridViews. The second is that Databinding in Silverlight CANNOT do indexes or any other special kind of binding (http://msdn.microsoft.com/en-us/library/cc189022(VS.95).aspx) it only supports property bindings. So the idea of just binding to array[index] cannot be done. The third is there is no manual way to add rows to the DataGrid. You can only set ItemsSource. Its like they ca

So the only way to feed the Datagrid is to have a class collection with the properties you need. So obviously Microsoft does not want you to have dynamic datagrids. One work around is to use IConvertor (http://blogs.msdn.com/deepak_verma/archive/2008/07/19/dynamic-creation-binding-of-silverlight-datagrid.aspx) But this only allows one way databinding and for my project it requires two way databinding. So I obviously can’t use that.

Other people have concluded the only way around this is to use code generation to create the classes with the properties they need. As cool and powerful as code generation is, I find it to be buggy, hard to debug, and generally very nasty to work with. Since I didn’t have the time or energy to write my own CodeGen solution and can’t use any 3rd party code I figured out another solution that is easier to do, works, but is potentially very slow for Grids with a large number of columns.

Basically you use a linked list for your row. This can be done because every element in a linked list is accessible via a property. The “Next” property in a link list is what makes this possible and what can make it slow. To access the nth column you just have n-1 “Next”s in the Path followed by “Value”. In the code below I am setting a column’s Binding property.

column.Binding = new Binding(CreatePath(columnIndex));

string
CreatePath(int columnIndex)
{
StringBuilder result = new StringBuilder();
for
(int index = 0; index < columnIndex; index++)
{
result.Append("Next.");
}
result.Append("Value");
return
result.ToString();
}


When creating the actual ItemsSource create a list of link list nodes and fill it with the first node from each row. In the below code the trueSource is just a sample collection that would work.


var
trueSource = new object[][]
{
new []{ "Row", "One" },
new
[]{ "Row", "Two" },
};

List
<LinkedListNode<object>> itemSource = new List<LinkedListNode<object>>();
foreach
(var item in trueSource)
{
var row = new LinkedList<object>(item);
itemSource.Add(row.First);
}
dataGrid.ItemSource = itemSource;


There you have it. It’s very hacky, it’s potentially slow and code generation is your only other option (that I know of). Microsoft really dropped the ball on this one.

If you have yet to figure out why it can be slow here is the reason: let’s say you have 32 columns in order to bind to the last element the “Next” property has to be called 31 times to get to the node that contains its “Value”. That is 31 extra calls then a direct binding. Since data binding uses reflection that will make it even slower. But with machines being so fast as they are now I doubt you will notice the speed hit, unless you have a lot of columns and a lot of rows. If that’s the case Code generation and all its hair pulling fun is your only other option (that I know of).

Tuesday, October 14, 2008

Drop Down Buttons for WPF

The problem is the DropDownButton for WPF does not exist. And if you are like me you need one but really don’t want to have to write one. The most common scenario for drop down buttons is putting them in a toolbar. I have found a simple way to emulate the drop down button exactly without writing a line of code. Just use put a full blown Menu in.

Thursday, July 31, 2008

Another Captcha Idea (Identify/Captcha)

With the recent failures with the captcha for gmail and other major mail service providers it has became apparent that captchas need to be improved. So I pondered on this for a while and a came up with the identify/captcha idea where you have the standard captcha but you also include a background image that has items the user has to identify. Here is a mockup of what I am talking about:





The background itself being something other then whitespace would trip up the bot makers for a while but the real kicker is the “What is in the picture?” bit. Having 6 check boxes gives 64 possible answers that’s a 1/64 chance of a bot guessing it right. If the bots get the text right 1/3 of the time then that is a 1/192 chance of the bot answering correctly. Sounds like a good odds to me.

Now let’s think about how to break this system (what the bot makers would think) well they could easily create a database of pictures and correct answers. So to foil that we will need a very large collection of pictures to make the DB unmanageable and we need to distort the pictures to make any hashing attempt fail. The rest is left as an exercise for the reader.

Now all is needed is for me to convince Google to start using this.

EDIT:

My brother pointed out that having to have a database of images is pretty much unacceptable because image recognition can eventually defeat any distortions. So to make this idea better the image should be a 3d rendering of the objects with random textures, positions and angles and lighting making it so you can have a virtually unlimited number of images with objects in it. This would force the bot makers to actually do object recognition. This idea is more processor intensive but you will no longer have to store the Database or create it.


Thursday, July 10, 2008

Modifying collections inside a constructor.

I’m adding this to a list of no nos.

Imagine you add the object to a collection inside the constructor. Then throw an exception? Well when you get an incomplete object inside the collection.

Saturday, June 28, 2008

Silverlight is too light.

I’m trying to make a game using my physics engine and silverlight and the engine mostly works setting the compact framework symbol gets rid of most of the compiler errors. But one error that really annoyed me was that it said List.RemoveAll was missing. Talk about annoying. I use it several times in the engine so it can’t be allowed to be missing.

I’m just glad that they allow extension methods that way I can re-add the functionality they took out.

But why remove that method? I know with silverlight they are trying to trim off the fat, but this is more like cutting out the muscle.

Wednesday, June 4, 2008

The Search for the Perfect Database.

I have been searching for a database to use in a certain application for years. And none of them ever quite met all my needs until now. The program needed a database for each machine it ran on so the first requirement was that is had to be embeddable and not have a separate install. This eliminated a majority of the mainstream database systems out there. I also wanted this database to work on both Linux and Windows. I found Firebird which actually worked well for me, but had a few issues. They were the lack of good online documentation and the bug prone Ado.Net provider; which leads to my next requirement it had to have an interface with .Net. After working with firebird for a long time I finally decided to shift my database from firebird to another system. VistaDB 3 looked really appealing to me because of it being completely managed. I even switched over to it for a while, but the documentation was lacking and it ran slow (and didn’t want to spend the time fixing that.), and would have to buy it. That was when I found H2, but it had one problem it’s a Java database. In order to use it I used IKVM.Net. But I then had another problem H2 had no ADO.Net interface so I wrote one. Thus H2Sharp was born. So far I have been pleased with H2 and my only issue so far is the ~20MB class library that comes with IKVM.

I have looked at nearly every database out on the market and have tried a few of them. So here is a list of databases I considered or used.

MS SQL Express (Used):
Windows only, separate install, resource hog, not embeddable.

SqlCE(Considered)
Windows only, lack of needed features.

db4o(Considered):
Viral GPL or pay big bucks, also was too different.

SQLite (Considered):
Not Managed, bad concurrency, ADO.Net interface was buggy.

DB2 (Considered):
The free version was not embeddable and had artificial limitations and had to pay for embeddable.

Oracle (Considered):
The free version was not embeddable and had artificial limitations, separate install.

SharpHSQL (Considered):
Power loss causes corruption, did not seem to be in active development.

IBM cloudscape, Apache Derby, JavaDB (Considered):
Would have had to install Java and .Net and have it run in a separate process.
(Considered it before I found IKVM.Net and found H2 before I found IKVM.Net)

FireBird (Used):
Embeddable only on windows, lacking documentation, ADO.Net interface was buggy.

VistaDB(Used):
Lacking documentation, speed was slow, had to buy.

H2 (Using):
Needs IKVM.Net’s ~20MB dlls for .Net usage. Needs H2Sharp.

Monday, June 2, 2008

Open up a cafepress Store.

I have created a CafePress store with 3 different shirts. This was because I thought of an idea for a funny T-Shirt (the empathy one); I added 2 other shirts that are from art I’ve created. Take a look. Now the place is rather expensive and I only get about 1 dollar if you buy one, so only buy them if you really want them.


here is a link.

Thursday, May 22, 2008

The worship machine.

It’s a rather simple concept probably already done. It was thought up because of a small group I attended had a worship session where all we did was listen to music. I ask why and one of my friends said it’s a new song and didn’t know the words. The Bible says “Make a joyful noise unto the LORD, all ye lands” (Psalm 100:1) not just listen to a joyful noise. So I thought up of this concept.

Take a karaoke machine and modify it to project the words onto a wall and program it with Christian songs. Or take a computer with a projector and run a karaoke program with Christian songs. As I said it’s rather simple. This would allow small groups to have a worship session that would allow them to sing God’s praises not just listen to a CD of someone who did that a while ago.

Tuesday, May 20, 2008

The evil company’s clock.

I just thought of something interesting. The evil company’s clock. It would be a clock that from 9 AM it would make each hour 15 minutes longer then after 5 PM it would make each hour 7.5 minutes shorter. Thus if a employee trusts this clock he/she would work 2 hours more and only charge for the usual 8.

So if your company offers free clocks beware!

Wednesday, March 19, 2008

Thursday, February 21, 2008

Jade Empire: The Installer.

I recently tried to install Jade Empire. So far it has taken over 2 hours. The most annoying part of it is that a majority of the time it is doing nothing! Absolutely Zero processor usage! It’s as if the programmers decided it was a good idea to add a few random calls to wait/sleep. This makes me angry, I don’t sit down after a long day at work and say “what game do I want to watch install today?” I remember my dad once said playing games is a waste of time, so far Jade Empire has proven him right.

Update: It was the DVD drive I used that Jade Empire did not like.

Tuesday, February 19, 2008

Creating Unions in C#

Here is a Small trick to create a C/C++ like union in C#.

          You have to use the StructLayout attribute applied to the class. the StructLayout attribute needs to be passed the parameter LayoutKind.Explicit. This makes it so you can declare the exact offset in the number of Bytes each field will have. Naturally you will need to use another attribute for each of the fields to specify this offset; the name of this attribute is FieldOffset. Both of these Attributes are in the System.Runtime.InteropServices namespace.



Here is an example where 2 32bit integers will share the same memory address as a 64bit integer.


using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Explicit)]
public
struct PairID
{
[FieldOffset(0)]
public
long Id;
[FieldOffset(0)]
public
int LowId;
[FieldOffset(sizeof(int))]
public
int HighId;
}

Decided to Create a Blog.

I have decided that I should finally make a blog, though I don’t really have time to maintain one. People around me have started to show signs that I annoy them with my ideas, so I decided to see if the internet that is comprised of complete and utter strangers will care about my random thoughts.