Integrating JTK with tinyMCE 4.x

Integrating my Javascript Thaana Keyboard library to handle Thaana entry within tinyMCE for a full-featured rich-text Thaana editor is very straightforward. You just need the following config in the tinyMCE initialization.

setup: function (editor) {
      editor.on('keypress', function (e) {
          thaanaKeyboard.value = '';
          thaanaKeyboard.handleKey(e);
          editor.insertContent(thaanaKeyboard.value);
      });
}


Enjoy!


My strategy for the lowest unique bid auction @ win.mv

So, I won a SMS-based “lowest unique bid auction” type game run by win.mv that had offered a nice quadcopter drone with gimbals and a GoPro camera. Saddeningly, some are unhappy with the outcome and have resorted to squaring accusations of cheating and insinuated that I had used illegal means towards winning. Some have even launched smear campaigns against both win.mv and myself via mass SMS and the Maldivian Facebook and Twitter spheres. Here, I’d like to clear up a few things…

My interest and approach to the game:


I am not someone who participates in raffles, lotteries (“naseebu numbaru”) and other types of competitions that are based on pure chance because the probabilities of winning one are so low and there is nothing one can do to increase their odds. I came across the win.mv advertisement on Facebook a day or so after it was launched and read up on what a “unique bid auction” is as it was the first time I had heard of the term. The realization that it wasn’t a game of pure-luck, the mathematical analyses mentioned on the Wikipedia page and the game theory-centric approaches discussed in the research papers I had found, piqued my curiosity and interest enough for me to decide to take a shot at it. I’ve wanted a drone for a while and having a good chance of getting one as reward for geeking out on an interesting mathematical/computer science problem had me hooked!

It is worth noting that a lowest unique bid auction is very similar to a raffle if the only information you are given is that your bid amount is the current winner – in which case you are down to making blind guesses and hoping you luck out. Some lowest unique bid auctions also run on the rule that submitting a new bid that is not unique while already holding the winning lowest unique bid switches you to the non-winning position – in which case participants tend to not risk exploring other possible bid values for fear of loosing some advantage they might have at some point. Hence, the exact implementation and the information provided during the game by the organisation running it matter a lot.

Information provided by win.mv:

The game run by win.mv was offering several bits of information that slightly swayed the odds for players.

  1. +/- < 1 range where the current winning bid was placed
    They provided this bit of information on their website for the current winning bid until the last few days of the game. +/- 1 is a very small range where the total SMS value to the player is RF 100/- to cover the entire range. One could send out submissions to cover this entire range and have a good chance of ending up with a winning bid. If you were to log this information frequently (like I did), then you can build up a map of the number line where gaps become apparent.

  2. Replies indicating whether the bid was > or < than current winning bid
    This is very helpful in quickly tracking down a range where the current winning bid is and was especially helpful once the website stopped showing the range of the current winning bid. For example, if you sent a submission of 10 and got a reply that it was lower than the current winning, then you could either step through incremental submissions, with a step resolution of your choosing, until you are told that your bid is larger than the current winning bid (or hit a winning lowest unique bid in the process).

  3. Replies indicating that you have a unique bid but not the lowest
    This is somewhat handy because you know you’ve struck a unique bid that can come back to your advantage if you or someone else knocks out the current winning bid by duplicating it. The strategy then may move to sounding out the winning bid using the process described in (b).

  4. Replies that your submission is rejected because you are the current winner
    I discovered this by accident but it was pretty useful. If you are the current winner and make a submission that is not unique then you not given a rejection reply but given the same message as (b) instead. However, if you make a submission that is unique, the system replies with the rejection message. This allows you to keep submitting and noting down bids that have a chance of being unique when used later if you lose the current winning spot.

  5. Duplicate bids
    They displayed this bit of dynamically updated information on their website until the end of the game and is a helpful guide for what bid amounts to avoid submitting to save your SMS expenses. If you were to log this information frequently (like I did), then you can build a list of bid amounts to not ever submit and use your budget more efficiently.



Observations/Assumptions:

All that information gives a good insight into the landscape of the game at any given time. But you do need a few other observations and assumptions to maximise your chances.

  1. The duration of game
    The win.mv competition ran for about a month (?) which gave plenty of time for even a few active participants to quickly use up more bid amount ranges (more time, more submissions).

  2. Number of people participating
    This is pretty important because, in combination with point (i), more people participating means a larger number of submissions and higher probability of a larger bid amount range being filled. However, given that Maldives is only ~300,000 people, of which a small subset will take part in the game, and this being the first such game by win.mv which probably would lead to many people being unaware or unwilling to take part, meant that the probability of the bid amount range having gaps was high - which is a good thing.

  3. Amount willing to spend
    It gets tricky here because the more the participants are willing to spend, the larger the bid amount range that will get covered. This then increases the cost of participation and winning. Having a good guess of what others might be willing to spend and setting your budget appropriately helps come up with a strategy that gives you a good chance of winning. For example, if you are willing to spend RF 100, and someone else is willing to spend just 1 RF more than you, the other person has a much better chance even with simple strategies. I opted for a budget of RF 3000.



Strategy:

There is no perfect play (a strategy that guarantees a win) in unique bid auction games but there are a few approaches you can take to increase your odds.

  1. Cover a continuous part-range of expected values
    This is a very good approach if you have a large enough budget. This approach involves sending all possible bid values starting from whatever max value you think will give you a good chance of winning as informed by assumptions (ii) and (iii) down to 0.01. This strategy means you will have to spend quite a bit upfront but means that other players have to send a whole lot of submissions to nullify your submissions and any gaps they leave will leave you a winner.

  2. Cover a large range with stepped values or random-ish values
    This approach is more budget efficient than (i) and involves making submissions by stepping through your values (e.g. 0.2, 0.4, 0.6 or 0.5, 1.0, 1.5 etc) or with random values that cover a broad spectrum of the possible values as informed by assumptions (ii) and (iii). If you loose the winning spot when someone uses up a gap you left, you can easily track it down and invalidate theirs by duplicating the bid.

  3. Mix of (1) and (2)
    It is possible to mix (1) and (2) for a double pronged approach that is even more budget efficient but at the cost of having to keep up with active play in the game till the end. This approach also carries much higher risk. I decided to use this method because it would cost me less and be a more fun computational challenge.


I used the logged information from (a) and (d) to optimize the bid submissions I made.

Tools:

Playing to win makes this game unplayable if you are sending SMS by manually typing it in, especially during the frenzy of the end of the game where other participants are all actively sending tens or hundreds of submissions. This is especially true for the strategies (1) and (2). You can gain a speed advantage by using tools to aid you. You can send out a large number of SMSes for this purpose using freely available SMS software hooked to your phone and MS Excel to list or generate the numbers or, if you are a programmer, write a few lines of code to automate most or the whole process.

Comment on the accusations:

One of the main accusations that is being levied is that I am friends with and colluded with Apo, one of the guys running win.mv, to rig the whole thing in my favour. Apo is an acquaintance, one of the many talented developers that I have had the fortune of meeting from the relatively small group of software developers in Maldives. He is not someone I hang around with at all or talk to often. I can’t imagine any reason that he or the other guys behind win.mv would have for rigging the competition in my favour.

The other accusation is that I used illegal means, somehow accessing or hacking the auction systems, to gain some advantage not had by others. There’s little I can offer than my word that I did not do any such thing but I heartily join the calls for an investigation by the relevant authorities to ensure there was no fraud or scam or illegal activity by any and all participants of the game.

It maybe worth noting that quite a few people complaining on the win.mv Facebook page and elsewhere, seem to have very little understanding of how a lowest unique bid auction works. It is complex and involved and there are common scenarios where a winner and a winning amount changing wildly can happen, especially under heavy submission traffic, and is hardly indicative of foul play.

---

In the end, I am not sure if it was all the reading and my imagined-clever strategy and system that helped me win or was just pure luck - I like to think my work helped - but I am sure I played fair and spent a lot for my effort. Judging by the hate and threats some people are spewing, I am better off never participating in these things in Maldives. Thanks for the lovely prize win.mv! :-)

My talk on "Curiosity" at MINDTalks

I recently gave a talk at the 3rd instalment of MINDTalks. My talk focussed on curiosity and how it has guided and impacted my life.

MINDTalks, is a series of events "about passing of knowledge, information, experiences and amazing stories" being organised and held by MINDFields Inc. I thank them for inviting me to speak at their event. The founders of MINDTalks say they hope to inspire and motivate people in the Maldives.

You can watch my talk (embedded below) and other talks at the MINDTalks channel on Youtube. I hope you find my talk, which was mostly candid and impromptu, interesting and inspiring.

25th April Partial Lunar Eclipse visible in Maldives

Partial lunar eclipse tonight will be visible in Maldives. The partial phase will last just 27 minutes (2nd shortest for the 21st century!) as the Moon lightly grazes the umbral shadow. Starts 23:03 25th April, ends 03:11 26th April. Best viewing time around 1 am.

More details available at Partial Lunar Eclipse of April 25 (NASA)

Details on near-Earth asteroid visible in Maldives tomorrow - މާދަމާ ދުނިޔެ ކައިރިޔަށް އަންނަ އެސްޓްރޮއިޑްއާއި ބެހޭ

މާދަމާ (15 ފެބުރުއަރީ) ދުނިޔެއާއި ވަރަށް ކައިރިން އެސްޓްރޮއިޑެއް ދާނެކަމަށް ފަލަކީ އިލްމުވެރިން ބުނަމުންދާތާ ދުވަސް ކޮޅެއްވެއްޖެއެވެ. އަދި މިފަހަރު ކަންދިމާކުރާގޮތުން މިއެސްޓްރޮއިޑް ދިވެހިރާއްޖެއަށްވެސް ފެންނާނެއެވެ. ހަމަ ލޮލުން ފެންނަވަރަށްވުރެ ކުޑަ ތަންކޮޅެއް ފަނޑުކަމުގައިވިޔަސް، ދުރުމީ ނުވަތަ ޓެލެސްކޯޕެއްގެ އެހީގައި ބަލައިލެވޭނެއެވެ.

މިއެސްޓްރޮއިޑް ރާއްޖެއަށް ފެންނަގޮތަށް ފެނުން މައްޗަށް އަރާނީ ގާތްގަޑަކަށް 15 ފެބުރުއަރީގެ 22:00 ޖަހާއިރު ދެކުނުންނެވެ. ނަމަވެސް ފަސޭހައިން ފެންނަފަށަށް އަރާނީ 23:00 އިންފެށިގެންނެވެ. އޭރު ހުންނާނީ ކްރަކްސް ނުވަތަ ސަދަން ކްރޮސް ކޮންސްޓެލޭޝަން ކައިރީގައެވެ. އަދި 16 ފެބުރުއަރީގެ 00:30 އާއި 01:00 އާއި ދެމެދު ހުންނާނީ ވާގޯ އާއި ލިއޯ ކޮންސްޓަލޭޝަން އާއި ދެމެދެވެ. މިވަގުތަކީ މިއެސްޓްރޮއިޑްގެ ދުނިޔެއާއި އެންމެ ކައިރިވާ ވަގުތާއި ކައިރި ވަގުތެއްކަމުން އޭގެ އަލި އެންމެ ގަދަވާނެވެސް ވަގުތު ކޮޅެކެވެ. މިތަކެތި ފަސޭހައިން ހޯދުމަށް ފޯނަށް "ގޫގްލް ސްކައި މެޕް" (އެންޑްރޮއިޑް) ނުވަތަ "ސްޓާ މެޕް" (އައިއޯއެސް) ފަދަ އެޕެއް ބޭނުން ކުރެވިދާނެއެވެ.


އުޑުމަތިން "2012 DA14" އެސްޓްރޮއިޑްގެ ދަތުރު ފެންނާނެގޮތް – ހެވަންސް އެބަވްއިން


އެސްޓްރޮއިޑް މިހާރު ހުރިތަނުގެ އެންމެ ފަހުގެ މައުލޫމާތު - ނާސާ


"2012 DA14" ގެ ނަންދެވިފައިވާ މިއެސްޓްރޮއިޑަކީ ދުނިޔާއި ގާތުން ދަތުރުކުރާ ދުންތަރިތަކާއި އެސްޓްރޮއިޑްތަކުގެ އާއިލާ ("ނިއާ އާތު އޮބްޖެކްސް") އަށް ނިސްބަތްވާ އެއްޗެކެވެ. މީގެ ބޮޑުމިނަކީ ގާތްގަޑަކަށް 150 ފޫޓެވެ އަދި ބަރުދަނަކީ 130000 މެޓްރިކް ޓަނެވެ. މީތި ފުރަތަމަ ހޯދިފައިވަނީ 23 ފެބުރުއަރީ 2012 ގައެވެ. ހިސާބުތަކަށް ބަލާފައި މި އެސްޓްރޮއިޑް ދުނިޔެއާއި އެންމެ ކައިރިވާނީ 16 ފެބުރުއަރީގެ (ރާއްޖެގަޑިން) 00:24ގައިކަމަށާއި އެވަގުތު އެންމެ ކައިރިވާނީ އިންޑިއާ ކަނޑުން ސުމަޓުރާ ބޭރުން ކަމަށް ސައިންސްވެރިން ވަނީ ވިދާޅުވެފައެވެ. ގައިއަކު 28100 ކިލޯމީޓަރު ނުވަތަ ސިކުންތަކު 7.82 ކިލޯމީޓަރުގެ ބާރު މިނުގައި ދުނިޔެއާއި ދިމާލަށް ދަތުރުކުރަމުންދާ މިއެސްޓްރޮއިޑް ދުނިޔޭގެ ސިސްޓަމް ތެރެއިން ބޭރަށް ދާނީ 16 ފެބުރުއަރީގެ (ރާއްޖެ ގަޑިން) 17:00 ގައެވެ.

މި އެސްޓްރޮއިޑް ދުނިޔެއާއި އެންމެ ކައިރިވާ ވަގުތު މިއެސްޓްރޮއިޑާއި ދުނިޔެއާއި ދެމެދު ދުރުމިނަކަށް ހުންނާނީ އެންމެ 27700 ކިލޯމީޓަރެވެ. މިއީ ދުނިޔޭގެ ވައިގެ ފަށަލައައްވުރެ މާދުރެވެ އަދި ބައިނަލް އަގުވާމީ ޖައްވީ ސްޓޭޝަނައީ ދުނިޔެއާއި ކައިރި ބުރުޖެއްގައިވާ ތަފާތު ސެޓެލައިޓްތަކަށްވުރެވެސް ދުރެވެ. ނަމަވެސް މިއީ ޖީޕީއެސް އަދި ތަފާތު މުވާސަލަތީ ސެޓެލައިޓްތައް ދަތުރުކުރާ "ގިއޯ ސިންކްރޮނަސް އޯބިޓް" އޭ ކިޔާ ބުރުޖައްވުރެ ކައިރިއެވެ އަދި ހަނދަށްވުރެ ގާތްގަޑަކަށް ދިހަބައި ކުޅަ އެއްބައި ކައިރިއެވެ! އެއްވެސް ސެޓެލައިޓެއްގައި މީތި ޖެހުމުގެ ބިރެއް ނެތްކަމަށް ސައިންވެރިން ވަނީ ވިދާޅުވެފައެވެ.

މިބޮޑުމިނުގެ އެސްޓްރޮއިޑެއް ދުނިޔެއާއި މިހާކައިރިވާނެ ކަމަށް މިހާތަނަށް ހޯދިފައިވާ "ނިއާ އާތު އޮބްޖެކްސް"ގެ އަލީގައި ބެލެވޭ ފަހަރަކީ މިއެވެ. މިއެސްޓްރޮއިޑް ބަލަން ރާއްޖޭގެ ހުރިހާ ހިސާބެއްހެން ކަމުދާނެއެވެ. ނަމަވެސް އިރަށްވާ ރަށްތަކަށް ކުޑަކުޑަ މޮޅުކަމެއް ލިބިދާނެއެވެ.

މިފަހަރުގެ މިބައްދަލުވުމުގައި ދުނިޔޭގެ ގްރެވިޓީއާއި ހެދި މީގެ ބުރުޖަށް ބަދަލުތަކެއް އަންނާނެއެވެ. ދެން ދުނިޔެއާއި އެންމެ ކައިރިޔަށް މިއެސްޓްރޮއިޑް އަންނާނީ 15 ފެބުރުއަރީ 2046 ގައެވެ ނަމަވެސް ދަތުރުކުރާނީ މިފަހަރުހާ ގާތަކުން ނޫނެވެ.
ދުނިޔާއި ގާތުން ދަތުރުކުރާ މިފަދަ ތަކެއްޗަކީ ދުނިޔައަށް ނުރައްކާ ހުރި ތަކެތި ކަމުން ސައިންސްވެރިންނާއި ދުނިޔޭގެ ބޮޑެތި ގައުމުތަކުގެ އަސްކަރިއްޔާއިން ބަލަމުން ގެންދެއެވެ. ނަމަވެސް މިފަހަރަކު ދުނިޔެއަށް މާބޮޑު ނުރައްކަލެއް ނެތްކަމަށް އެތީގެ ބުރުޖާއި ސުޕީޑާއި ތަފާތު ކަންކަމަށް ބެލުމަށްފަހު ސައިންސްވެރިންވަނީ ޔަގީންކަން ދީފައެވެ.

ދުންތަރިއާއި އެސްޓްރޮއިޑަކީ ތަފާތު ދެއެއްޗެކެވެ. މިދެއެއްޗަކީވެސް ފަޒާގެ ތެރޭގައި ދަތުރުކުރަމުންދާ އެއްޗެއްކަމުގައިވިޔަސް އެސްޓްރޮއިޑަކީ މައިގަނޑު ގޮތެއްގައި ގަލެވެ އަދި ދުންތަރިއަކީ މައިގަނޑު ގޮތެއްގައި ގަނޑުވެފައިވާ ތަފާތު ގޭހައި ފެނެވެ. އަހަރެމެންގެ ސޯލާސިސްޓަމްގައިވާ ހުރިހާ ދުނިޔެތަކެއް ފަދައިން މިސޯލާސިސްޓަމްގެ ތެރޭގައިވާ އެސްޓްރޮއިޑްތައްވެސް ދައުރުކުރަނީ އިރުގެ ގްރެވިޓީގެ ބާރާއި ހެދި ހަމަ އަހަރެމެންގެ އިރުވަށައެވެ. އެހެނިހެން ދުނިޔެތަކުގެ ގްރެވިޓީގެ ބާރާއި ހެދި އެތަކެތީގެ ބުރުޖަށް އަންނަ ބަދަލުތަކާއި ހެދި ބައެއް އެސްޓްރޮއިޑާއި ދުންތަރި ދުނިޔޭގެ ބުރުޖާއި ކައިރިވެ އަދި ބައެއް ފަހަރު ދުނިޔެއާއި ޖެހި މުޑިއަރައެވެ. މިގޮތަށް މުޑި އެރުމަކީ އަހަރެމެންނާއި ދުނިޔޭގައިވާ ދިރުމަށް ހުރި ބޮޑު ނުރައްކަލެކެވެ. ދުނިޔޭގައި އިންސާނުންގެ ކުރިން އުޅުނު ބިޔަ ޖަނަވާރުތަކެއްކަމުގައިވާ ޑައިނަސޯތައް ނެތި ދިޔައީ ވަރަށް ބޮޑު އެސްޓްރޮއިޑެއްގެ ސަބަބުންކަމަށް ސައިންސްގެ އަލީގައި އެނގެއެވެ.

What really bugs me: Starvation

It maybe be less dramatic than war. It maybe scattered over several countries you've never heard of. It may not get much media coverage. It maybe a long term, amorphous, complicated problem. But what really gets to me and makes me depressed and literally tear up, everyday, is that about 25,000 people die every day from hunger or hunger-related issues, most of whom are children.

Imagine kids going for weeks without a decent meal, that they feel weak, confused and tired like you've never ever been, that they can't get proper sleep and hallucinate when awake, that they constantly feel cold and shaky, that their immune system is so shot that any minor disease or illness is a major threat, that their organs start to shutdown and bring about agony like you've never ever felt until they finally die. That's what starvation entails.

What do I think is the biggest injustice? That the world as a whole produces enough food that starvation should be history. But greed and lack of political will, among others, mean that starvation sustains and remains an ever present threat in many places across the Earth.

Where's the outrage?

Fucked up world we live in.

Dhives – A free Dhives Akuru font

Earlier this year, Nattu and I took a break from work to work on something fun and different. The result: A Dhives Akuru font. We published this a while back at the Semicolon blog, I'm posting it here just for reference.



I admit the font is very unpolished. I should have spent more time cleaning it up but I had to spend a whole lot of time reading up, learning how Dhives Akuru works, finding sample characters etc. I read pretty much everything I could find on Dhives Akuru on the web and learnt a whole lot about Dhives Akuru along the way. And it is a complex beast.

Dhives Akuru is the script used in the Maldives until it was replaced officially by Thaana as the official script for Dhivehi.

Get the font and read more on the post at the Semicolon blog:
- Dhives – A free Dhives Akuru font