I have an iPhone 3g (from the UK) and I live in Brooklyn, NY, so to allow me to use it I had to jailbreak it. In doing so I figured, “Why not enable multitasking?”. I’ll tell you why: I did, and its terrible, it makes the phone crawl at a snails pace. Simply loading the sms window takes a whole minute if you have a couple of applications in the ‘multitask window’. If you’re thinking of jailbreaking your iPhone 3g just to enable multitasking, don’t bother!

No one loves a good deal more than me, so I find it really frustrating that I can’t coupons for the local bars, restaurants and services around where I live.
Its clear that managing a successful coupon campaign can be a lot of work, so unless the business is the size of Macy’s, or you’re lucky and get picked for a groupon it’s pretty hard to make all the effort worthwhile.
It is with this in mind that I have created couponize.me, a (very) easy to use printable coupon maker. The goal of the site is to become a front-to-back coupon campaign management system for small businesses, so that anyone can create a successful coupon campaign with very little effort.
Currently the site allows you to create a simple printable coupon in three clicks, but I will be adding plenty of features (such as customizable templates) in the near future.
If you own a business, and you need to create a coupon, why don’t you give it a try.
Filed under couponize.me coupons project
I’m finally saying goodbye to the old matthewrathbone.com/blog .
I built the site back in 2008 using ASP.NET (which I was working with at the time) and its become a total pain to maintain, update, and style. It is with that in mind that I have moved my blog to http://tumblr.com.
I’m not sure whether I’ll be importing my old posts into this new blogging system, perhaps I will import the popular / important posts about the bloomberg API and algorithms, but I’m not promising anything.
Anyway, I hope you enjoy this better site, and please checkout my most recent project: http://couponize.me
This is the first post in my quest to be a better programmer. Quicksort is one of the ‘standard’ sorting algorithms. Its fairly easy to implement, and normally runs fairly quickly. I’ve implemented quicksort in both C and Scheme, although I think my Scheme implementation is more of a pseudo-quicksort due to a reluctance to break from the functional style encouraged by Scheme syntax.
Quicksort Overview
The ‘Partition’ algorithm is at the core of a quicksort implementation, and this partitions an array into groups of ‘less than x’ and ‘more than x’, with x itself being placed inbetween. The final position of x is the value returned by the partition function. In my simple implementation, the choice of x remains constant (either the first or last element). Randomizing this is the main way to increase the worst case speed of this algorithm.
After partitioning the initial input, quicksort recursivly calls itself on the ‘less-than’ and ‘more-than’ groups returned from partition. The result is a chain of recursive calls which continues until quicksort is trying to sort a single number.
Check out Wikipedia to get a more in-depth understanding of quicksort.
Special Property
Quicksort is good because it sorts ‘in-place’. In other words it doesn’t use a secondary array to sort the elements into. This can save a lot of memory, especially if you are sorting a list of complicated data structures which are a few KB each.
My C Implementation
void Quicksort(int A[], int p, int r){
if(p<r){
int q = Partition(A, p, r);
Quicksort(A, p, q-1);
Quicksort(A, q+1, r);
}
}
int Partition(int A[], int p, int r){
int j, temp;
int x = A[r];
int i = p -1;
for(j = p;j<r;j++){
if(A[j]<= x)
{
i++;
temp = A[i];
A[i] = A[j];
A[j] = temp;
}
}
temp = A[r];
A[r] = A[i +1];
A[i+1] = temp;
return i+1;
My Scheme Implementation
I think its worth noting that the scheme implementation doesn’t exactly sort ‘in-place’. Instead it recursivly builds up secondary lists then joins them together at the end as the return value instead of moving the elements around in a single list. However the amount of memory used should still be in the order of the number of elements in the input array unlike other sorting algorithms (counting-sort, and bucket-sort come to mind) which use secondary arrays which do not form part of the solution.
(define pHelper (lambda (all chk l m)
(cond ((null? all) (cons l (cons chk (cons m '()))))
(else
(let ((x (car all)))
(if (<= x chk)
(pHelper (cdr all) chk (cons x l) m)
(pHelper (cdr all) chk l (cons x m))))))))
(define partition (lambda (l)
(pHelper (cdr l) (car l) '() '())))
(define quicksort (lambda (l)
(cond ((null? l) l)
(else
(let ((lx (partition l)))
(append (quicksort (car lx)) (cons (cadr lx) (quicksort (caddr lx)))))))))
Filed under c scheme quicksort programming algorithms
The RTD / BDP functions provide real-time data from bloomberg directly to an excel sheet. However if you’re subscribing to fields which Bloomberg hasn’t designated to be ‘real-time enabled’ you have to manually refresh bloomberg data for it to have any effect.
Let’s look at an example
FUT_CTD_PX (Cheapest to deliver price) is a static FIELD for a real-time VALUE. IE, if you check in the BB terminal this value will be constantly changing, but excel sees it as a static field.
To get the CTD price for a future we can use the following formula:
=BDP(“SOME FUTURE’S TICKER”, “FUT_CTD_PX”)
This field will never update, it will stay static with it’s initial value. If the spreadsheet has been open for 5 days, it’s the price from 5 days ago which will be displayed.
Microsoft’s RTD server model is event driven, in that the data-source notifies the RTD server when a new value is available and that value is picked up by a spreadsheet when excel calls it’s RTD.RefreshData method (which it does every 2 seconds by default). In our example, Bloomberg’s data-source never notifies the RTD server of a change in value for any of it’s STATIC fields, and they therefore remain the same indefinitely.
This also explains why calling RTD.RefreshData from VBA code has no effect, as the RTD server has no new value to pass forwards.
Solutions
The only REAL solution is for Bloomberg to provide such key fields as real-time. Static fields should be reserved for values which do not change on a regular basis, such as instrument name, maturity date, ISIN, and so forth.
As a manual solution, Bloomberg does provide a Excel menu containing data-refresh commands. Clicking ‘refresh entire workbook’ will eventually update all static values (it can take up to 10 seconds), but only for the =BDP formula. If you’re using =RTD you’ll have to re-open your workbook or delete and re-type the formulas.
“Can I do this Programatically?” I hear you cry…. Why yes you can!
It’s not a graceful solution by any means but you can use one of the following to activate the respective bloomberg command:
be sure to wrap any use of these in good error checking to avoid Excel getting mad at the user.
Application.Run ("bloombergui.xla!RefreshData") [Default]
Application.Run ("bloombergui.xla!RefreshCurrentSelection")
Application.Run ("bloombergui.xla!RefreshEntireWorksheet")
Application.Run ("bloombergui.xla!RefreshEntireWorkbook")
Application.Run ("bloombergui.xla!RefreshAllWorkbooks")
Summary
It’s important to be aware that some bloomberg fields are not real-time. If you’re using one of these fields for a key calculation you’ll have to make sure that you manually refresh regularly, or that you have integrated a crude automation into your code.
Filed under real-time, bloomberg vba financial data finance scripting