Open-Sourcing My Music Composition Algorithm

Less than two years ago I wrote about the first version of my algorithm for music composition. Since then computoser.com got some interest and the algorithm was incrementally improved. Now, on my birthday, I decided it’s time to make it open-source. So it’s on GitHub. It contains both the algorithm and the supporting code to run it on a website (written with spring and hibernate). The algorithm itself is in the com.music package, everything else is in subpackages, so it’s easy to identify it. It isn’t a perfect piece of code, but I think it’s readable, if you happen to know some music theory. I am now preparing a paper to present my research (as some research is involved in the creation) as well as how the algorithm functions. Opening the code is part of the preparation for the paper – it will be noted there as a reference implementation. The license is AGPL – as far as I know, that should not allow closed-source use of my algorithm on the server-side. I don’t think making it open-source is such a significant step, but I hope it will somehow help algorithmic music composition advance further than it is today. Less than two years ago I wrote about the first version of my algorithm for music composition. Since then computoser.com got some interest and the algorithm was incrementally improved. Now, on my birthday, I decided it’s time to make it open-source. So it’s on GitHub. It contains both the algorithm and the supporting code to run it on a website (written with spring and hibernate). The algorithm itself is in...

Get Rid of the URL Pollution

You want to copy the URL of a nice article/video/picture you’ve just opened and send it to friends in skype chats, whatsapp, other messengers or social networks. And you realize the URL looks like this: http://somesite.com/artices/title-of-the-article?utm_campagin=fsafser454fasfdsaffffas&utm_bullshit=543fasdfafd534254543&somethingelse=uselessstuffffsafafafad&utm_source=foobar What are these parameters that pollute the URL? The above example uses some of the Google Analytics parameters (utm*), but other analytics tools use the same approach. And probably other tools as well. How are these parameters useful? They tell Google Analytics (which is run with javascript) details about the current campaign, probably where the user is coming from, and other stuff I and especially users don’t really care about. And that’s ugly. I myself always delete the meaningless parts of the URL, so that in the end people see only “http://somesite.com/artices/title-of-the-article”. But that’s me – a software engineer, who can distinguish the useless parts of the URL. Not many people can, and even fewer are bothered to cut parts of the URL, which results in looong and ugly URLs being pasted around. Why is that bad? website owners have put effort in making their URLs pretty/ With “url pollution” that efforts goes to waste. defeating the purpose of the parameters – when you copy-paste such a url, all the people that open it may be counted as, for example, coming from a specific AdWords campagin. Or from a source that’s actually wrong (because they got the URL in skype, for example, but utm_source is ‘facebook’) lower likelihood of clicking on a hairy url with meaningless stuff in it (at least I find myself more hesitant) If you have a website, what can...

Generating equals(..), hashCode() and toString()

You most probably need to override hashCode(), equals(..) and toString() – I won’t go into details when and why, but you need that (ok, just a reminder – always implement hashCode and equals together, and you most likely need to implement these methods if you are going to look up objects of a given class in a hashmap or an arraylist). And you have plenty of options to do it: Manually implement the methods – that’s sort-of ok for toString() and quite impractical with hashCode() and equals(..). Unless you are pretty certain that you want a custom, well-considered hash function, then you should rely on another, more practical mechanism Use the IDE – all IDEs can generate the three methods, asking you to specify the fields you want to base them on. The hash function is usually good enough, and the rest just saves you from the headache of writing boilerplate comparisons, ifs and elses. But when you add a field, you shouldn’t forget to regenerate the methods. commons-lang – there’s EqualsBuilder, HashCodeBuilder and ToStringBuilder there, which help you write the methods quickly, either with manual append(field).append(field), or with reflection, e.g. reflectionEquals(..). Adding a field again requires modifications, and it’s easy to forget that. guava – very similar to commons-lang, with all the pros and cons. Guava has Objects and MoreObjects, with helper functions for equals(..) and hashCode and a builder for toString() – you still have to manually add/compare each field you want to include. project lombok – it plugs into the compiler and turns some annotations into actual implementations, sparing you writing the biolerplate code completely. For...

Suggestion for Spam Filters

One of the issues with spam is false positives. “Did you check your spam folder” is often a question to ask if your email is not received on the other end. I’m not a machine learning expert and I’ve never made a spam filter, and I only know the naive Bayes approach. So this suggestion is not a machine-learning “breakthrough”. But from what I know about classification algorithms is that they usually provide a likelihood of one item being in one group or another. Some items are not identified as spam with absolute certainty – they are 51% likely to be spam, for example. My suggestions is: for borderline items (lower certainty that they should be classified as spam), the spam filter should send emails to the sender indicating that his message was considered spam. A genuine sender will probably take additional steps, like sending another short email or calling/messaging the recipient (‘click here to confirm you are not spam’ won’t work, because it will easily be automated). It’s rather a usability suggestion than a technical one, and I’m sure there are some issues that I’m missing. But I thought it’s at least worth sharing. One of the issues with spam is false positives. “Did you check your spam folder” is often a question to ask if your email is not received on the other end. I’m not a machine learning expert and I’ve never made a spam filter, and I only know the naive Bayes approach. So this suggestion is not a machine-learning “breakthrough”. But from what I know about classification algorithms is that they usually provide a...

RabbitMQ in Multiple AWS Availability Zones

When working with AWS, in order to have a highly-available setup, once must have instances in more than one availability zone (AZ ≈ data center). If one AZ dies (which may happen), your application should continue serving requests. It’s simple to setup your application nodes in multiple AZ (if they are properly written to be stateless), but it’s trickier for databases, message queues and everything that has state. So let’s see how to configure RabbitMQ. The first steps are not relevant only to RabbitMQ, but to any persistent data solution. First (no matter whether using CloudFormation or manual setup), you must: Have a VPC. It might be possible without a VPC, but I can’t guarnatee that, especially the DNS hostnames as discussed below Declare private subnets (for each AZ) Declare the RabbitMQ autoscaling group (recommended to have one) to span multiple AZs, using: "AvailabilityZones" : { "Fn::GetAZs" : { "Ref": "AWS::Region" } } Declare the RabbitMQ autoscaling group to span multiple subnets using the VPCZoneIdentifier property Declare the LoadBalancer in front of your RabbitMQ nodes (that is the easiest way to ensure even distribution of load to your Rabbit cluster) to span all the subnets Declare LoadBalancer to be "CrossZone": true Then comes the specific RabbitMQ configuration. Generally, you have two options: RabbitMQ Clustering RabbitMQ Federation Clustering is not recommended in case of WAN, but the connection between availability zones can be viewed (maybe a bit optimistically) as a LAN. (This detailed post assumes otherwise, but this thread hints that using a cluster over multiple AZ is fine) With federation, you declare your exchanges to send all messages they...