Adding Extra MIME-types to WordPress.
-
Comments:
- here.
(Site Admin) → Options → Mime types
File Extension/Associated mime-type.
Add mime-type »
(Site Admin) → Options → Mime types
File Extension/Associated mime-type.
Add mime-type »
Hmm. That is new. Google Music.
I’m guessing it will now be better to use Google Music to check for artwork and so on than Amazon.com.
There is a mathematical problem called the Eight Queens problem, which one of my teachers mentioned in passing in a Lecture the other day. I was mainly surprised as I hadn’t heard of it before.
The theory is thus. Imagine you have an 8x8 chessboard, and 8 queens. Is it possible to place each queen on the chessboard so that it cannot be taken by (and therefore not take) any other queen?
Graham mentioned it was interesting to do with a recursive method.
I thought it was something that was a good candidate for Logic Programming.
To begin with, I broke the problem down a little. For instance, there is one unique and trivial solution with a 1x1 chessboard and one queen.
With a 4x4 chessboard, there are two solutions that are just mirrors of one another, one of which I found almost immediately by just thinking about it:
Notice here that as long as you do not put the first queen in a corner, you will get a solution.
Doing this gave me some thoughts as to how to automate the process. Each queen has an X and a Y coordinate, and in each case, every queen must have a unique X coordinate, and a unique Y coordinate. This prevents them being on the same row or column as another queen.
Then, some quick calculations showed that in each of these cases, the difference of the X and Y coordinates is unique also. This prevents them appearing on the same down-right diagonal. Note here that not every diagonal has a queen on it - in fact, only one more than half of the possible number of diagonals does.
Further along the same lines of thought, we need a way to test if they appear on the same down-left diagonal. Some further calculations showed this is given by the sum of the X and Y coordinates.
So, we have four simple rules for determining if a queen can take another queen.
In my prolog solution, I call this unsafe/2
.
unsafe([X1,Y1],[X2,Y2]) :-
X1 = X2;
Y1 = Y2;
X1 is Y1 + X2 - Y2;
X1 is (X2 + Y2) - Y1.
We can then reverse this rule to find a safe pair:
safe(A,B) :- \\+unsafe(A,B).
To find if a set of queens are all safe together, we have a nice recursive predicate, queens/1
:
queens([_]).
queens([Q1, Q2|Qlist]) :-
safe(Q1, Q2),
queens([Q1|Qlist]),
queens([Q2|Qlist]).
All that we need now is a method of generating permutations, and we are done. I’ll not post my perm/2
solution, since it is widely known.
queens8([[1,A],[2,B],[3,C],[4,D],[5,E],[6,F],[7,G],[8,H]]) :-
perm([1,2,3,4,5,6,7,8],[A,B,C,D,E,F,G,H]),
queens([[1,A],[2,B],[3,C],[4,D],[5,E],[6,F],[7,G],[8,H]]).
Calling queens8(X)
will return every possible combination that fulfils the requirements of the Eight Queens problem. There are 92, but these are not all rotation- and reflection-unique.
One solution is shown below.
This is not the first solution I found, just a nice one :)
The only thing I haven’t yet figured out is how to automate the extension of this to any size board. At the moment I also have a queens4
, queens5
, and so on set of predicates. It would be nice to generalise this to queens(N,X)
. It would also be kind of cool to show the number of solutions, rather than each solution. And a clever way to show only rotation- or reflection-unique solutions would be even better.
Channel 10 is pretty crap about how it plays House. They’ll advertise a new episode, and then play two old ones instead. It really pisses me off.
Last night, however, they played the season finale of House. It was truly excellent.
With Amber about to die, they decide to ‘wake her up’ so that Wilson can say goodbye to her. So, she is brought back to consciousness so that she can find out she is about to die.
I wouldn’t want this, or do this to my partner. Even if it means not being able to say goodbye. I think I’d rather never wake up. Jaq knows I love her, regardless of me having to say it.
If we had had a fight, then I was in a bus crash, that might make it different…
One of the best things about having a laptop as my primary machine is that I generally don’t have to worry about synchronising issues any longer. For instance, I used to have a USB Drive that was my “transfer device”, and I was endlessly copying data to and from it. This meant I had three or more copies of my data, but I sometimes wasn’t sure which was the most recent.
I bought Changes.app to use with my Source Control system(s), as it is nicer than FileMerge.app. And it meant I could support an independent MacOS X Developer. And I’ve been using it, sometimes “in anger” where some data has been corrupted.
Today, I wasn’t able to get onto the Wireless network properly, and had my data on my Laptop, but needed to run some SQL queries on a database on a Uni machine. I copied the files across (in a location where the WiFi worked), and then ran the queries on the Uni Machine, but made some changes to both sets of files at the same time.
When I sat down to merge them all, I happened to think to use Changes. I dragged both folders onto Changes, and it gave me a list of files that differed.
I was able to choose which parts of each I wanted to keep, and save them, and it made both files the same as the merged version.
I wasn’t really expecting this - I naïvely thought that it was a read-only process, but Changes made it pleasant.
I subscribe to 120+ feeds, from mostly MacOS X related sites, but a few others.
From 9am onwards today, I don’t think I got a single new news item.
This is just so that people who subscribe to my feed actually get at least one new item :).
(Update: Apparently something was wrong with NetNewsWire - It just wasn’t downloading anything. A restart of the application fixed it. 70 items - that’s much more like it ).
I really don’t respect or like Java as a language. I’m not going to go into reasons why here, but I am going to bitch about J2EE and Enterprise Java app development under NetBeans.
Now, I’m not just a clueless student annoyed with stuff that doesn’t work because I’m a gumby. I write enterprise applications in python, apache and SQL Alchemy for my day job. It shouldn’t be as hard as it is to develop in NetBeans.
For starters, if I deploy my code and it fails, I shouldn’t be able to redeploy it again and it works. Same goes for building. I have found instances where I can build and it fails, and then an immediate re-build succeeds. And I’m not talking “Clean Build”, just a regular ordinary build.
More to the point, if I do an “Undeploy and Deploy”, and I get a whole load of exceptions, I kind of expect that the deployment has failed. But if I then do a build, it works.
And, it appears that if I build without a fresh redeployment, it fails.
This is just build and deployment issues. I’ve also had instances where code has failed, when I was pretty fucking sure it should have worked. I was throwing exceptions all over the joint (or, more correctly, the JVM or some other bit of technology was), and they were meaningless. A redeployment and the associated re-build, and it worked.
Developing a similar application in python+SQL Alchemy is faster, doesn’t appear to run much slower, and is much, much easier to read later. Yet, it is not taken seriously, because it isn’t Java.
Ugh.
I ♥ SQL Alchemy.
I’m currently rewriting a database so that the schema definition is in SQL Alchemy, allowing for us to deploy it across a range of platforms with a bit more ease.
We had been using some sequence types to automatically set the primary key to a new unique integer. Think Autoincrement in Access, if that’s where you’ve done some database stuff, or in MySQL I believe it’s AUTO_INCREMENT.
In SQL Alchemy, you get to define Tables in python, like this:
log_table = Table(‘log’, metadata,
Column(‘IP’, String(15), primary_key=True),
Column(‘timestamp’, DateTime, primary_key=True),
Column(‘reqSize’, Integer),
Column(‘resSize’, Integer),
Column(‘time’, Float),
Column(‘reqName’, String(256)),
Column(‘reqData’, String(4096)),
Column(‘resData’, String(4096)),
Column(‘reqObj’, String(4096)),
Column(‘resObj’, String(4096)))
Now, if you need a sequence type, then you can use a Sequence() object. But what if you have existing data, which may or may not have holes, and you need to ensure you don’t have any collisions?
db.query(Person).order_by('id').all()[-1].id + 1
This will query and get the Person object with the highest id, and add one to it.
You can then use this as an argument to the Sequence() object, and it will only generate the sequence from that value onwards.
(While I wait for something to compile…)
Had to fill the car up with petrol this morning. Petrol prices are a touch under AU$1.60/litre, which is higher than it has ever been in Australia. It costs me about 3 hours of work to fill my car up.
Anyway, there was a bit of a line up at the servo, and another guy came out to serve. The woman in front of me did the shit that she wasn’t being served first (people behind me rushed over to his till), and swore at everyone and stormed out, leaving a newspaper and some chocolate bars on the counter. Did I mention she was a bit fat? And feral?
So, she stormed out, straight into her car, which she had apparently also filled up with petrol, and drove off.
The chick behind the counter didn’t really get her number properly, so I corrected her.
And scored myself a free coffee for it.
But it was worth if for the show alone.
Shopping today - had to buy some Nutella (Hazelnut Spread).
Noticed a couple of cheaper imitations. One was Foodland or Black and Gold brand. The other, well, was:
Nutkao new Cream.
Guess which one I didn’t buy.