What's on my mind

Group By Date in mongodb

I am using mongodb for tracking my website. I am saving date and time with ISODate , "time" : ISODate("2014-05-18T13:23:04.227Z") .

So, I wrote like that.

    "$project": {
        "y": {
            "$year": "$time"
        "m": {
            "$month": "$time"
        "d": {
            "$dayOfMonth": "$time"
    "$group": {
        "_id": {
            "year": "$y",
            "month": "$m",
            "day": "$d"
        count: {
            "$sum": 1
    $sort: {
        "_id.year": 1,
        "_id.month": 1,
        "": 1

First , need to separate the year , month and date. After that , make a group and then sort it.

EMV TLV Decoder For Objective-c

I couldn’t find the EMV TLV decoder for iOS. However, I found a PHP code on github. So, I port to iOS version. However, I only need decoder. So, ios code include only decoder.

#import "SGTLVDecode.h"

//some of your code
//usage it

NSDictionary *value = [SGTLVDecode decodeWithString:@"Your TLV String"];

NSLog(@"TLV %@",value);

Fixed Disqus For WinterSmit

I am using disqus for my blog. However, it has a problem. If the URL is include query string , comments can’t show and it’s showing new one. I found a solution JavaScript configuration variables of disqus.

We need to put correct URL at disqus_url variable. So, I put

var disqus_url = document.location.origin + document.location.pathname;

For jade template , it will look like

      |var disqus_shortname = 'myblogname'; // required: replace example with your forum shortname
      |var disqus_url = document.location.origin + document.location.pathname;
      |/* * * DON'T EDIT BELOW THIS LINE * * */
      |(function() {
      |var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      |dsq.src = '//' + disqus_shortname + '';
      |(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      | Please enable JavaScript to view the
      a(href='') comments powered by Disqus.
      | comments powered by
      span.logo-disqus Disqus

After that , there is no more problem about query string URL problem.

Xcode 5 Build With Post Action

I build the library(SDK) file for iOS. I have a one problem. That is to support both simulator and device. After building both simulator and device , I need to do

  1. copy the files from Debug-iphoneos folder to release folder
  2. change mylib.a to mylibDevice.a
  3. copy mylib.a from Debug-iphonesimulator folder to release folder
  4. change mylibSimulator.a
  5. After that merge with lipo -create mylibDevice.a mylibSimulator.a -output mylib.a

I always need to do when release the library.

It’s really troublesome for doing many time.

So, I decided to create the script in post-action.

Go to the Product > Scheme > Edit Scheme.

And then Duplicate Scheme because we will only do post action when it ready to release. Give a name , release build.

Chose the release build scheme and Build > Post Action.

post action

Click the + icon.

plus icon

Need to choose the target build in Provide build setting from .

I create a script like that

rm -r ~/Desktop/mylib
mkdir ~/Desktop/mylib
mkdir ~/Desktop/mylib/Device+Simulator
mkdir ~/Desktop/mylib/Device

cd ..
cd Debug-iphoneos
cp mylib.a ~/Desktop/eb/Device+Simulator/mylibDevice.a
cp -r mylib.bundle ~/Desktop/eb/Device+Simulator/mylib.bundle
cp -r usr ~/Desktop/eb/Device+Simulator/usr

cp mylib.a ~/Desktop/eb/Device/mylib.a
cp -r mylib.bundle ~/Desktop/eb/Device/mylib.bundle
cp -r usr ~/Desktop/eb/Device/usr

cd ..
cd Debug-iphonesimulator
cp mylib.a ~/Desktop/eb/Device+Simulator/mylibSimulator.a

cd ~/Desktop/mylib/Device+Simulator
lipo -create mylibDevice.a mylibSimulator.a -output mylib.a
rm mylibSimulator.a
rm mylibDevice.a

After ready to publish , I built the app that use mylib static library project for both device and simulator.

And then choose the release build and build again.

After that I got mylib static library on my desktop. Nothing to do anymore and ready to use.

Wordpress To Wintersmith

After moving to the wintersmith from wordpress, I have two problem.

  1. need to redirect old url to new url
  2. re-import old comments to new url
  3. re-import old images


Today, I moved to the wintersmith from the wordpress. Wordpress is amazing blog platform. However, I want to try a static generated blog instead of dyanmic. Actually there is no reason for changing to static page. After testing wintersmith , it is really fast. It is easy to use.

Pros : support markdown. Static pages. Really fast. Can use with github pages.

Cons : no full text search and use with google custom search. Need to use jade for creating template. Only few templates. You need computer to write blog.

I prefer wintersmith than jekyll because of node.js. I can customize if it’s require to change.


Haroopad Markdwon Editor

I used lightpaper , Mouapp , textastic and atom for writing markdown. However, I can’t satisfy with this editor. Lightpaper and Mou are not support GitHub Flavored Markdown. So, syntax highlight alwasy problem. Can’t export syntax highlight with pre and code with class.When I export , it should be like that

<pre><code class='objc'></code></pre>

However, it didn’t and I need to change manually.

Mou is too slow when write a lot of text. Lightpaper is really light weight and only problem with Github Flavoured Markdown and export. I don’t want to export text. I just want top copy HTML from markdown after writing.

Haroopad is exactly what I want but it still not support unicode character. Same like other web editor, cursor position wrong when I use Myanmar Unicode.

However, it’s light weight and support theme. It can export HTML to clipboard. So, I can paste it in my blog. The other best thing is , it support GitHub Flavored Markdown. I can export the syntax highlight text , table , etc.

It also support cross platform (mac,windows and linux) and it’s opensource.

Add new fonts in iOS 7

Install new font in iOS 7

iOS 7 allow to add new font. However ,font fallback can’t work in app at iOS 7.1. To install font , you need to create the mobileconfig file.


Logitech Powershell

I bought the logitech powershell for my iPhone 5s. Now, iOS 7 support controller however, it doesn’t support in many games. I bought this controller for GBA4iOS . It support the GBA games with iOS 7 controller. I played mario and megaman zero. So, I can’t play megaman zero with on screen controller because very hard to press L and R.

With iOS 7 controller , I can feel like real Gamebody with iPhone 5s. You can check supported games on logitech website. You can also chect at Pocket Gamer.

Currently I played Asphalt 8: Airborne , Bastion and Shadow Blade. The experience is different. With game controller and iOS 7, it feel like playing with handheld game console. It also include battery to charge your iphone. So, it can save your iphone battery when you play game a lot.

The problem of Logitech Powershell is there is no Analog stick and no L2 , R2 buttons. It’s very hard to play the first person shooter with powershell. You need to move your hand on screen for first person shooter game. It’s very hard to play. I can’t play dead trigger 2 and Respawnables with Powershell controller.


Cancel the xiaomi redmi order

The previous post , I ordered the xiaomi redmi at Fri 21 Feb. It got a lot of problem and made at payment at 22:50:29. I wrote , it’s hard to trust them. They can’t did well on my order. Sat 21 Feb , they sell again. They said they are start shipping on Saturday. However, my order is still Payment received and nothing changes. At monday most of the people received the phone. Other people start complain about their order is still showing Payment received and not change to process or shipping.

So, I contact the chat support and they didn’t see any update on my order. Please wait. It’s not helpful answer. 25 Feb, all the people who ordered at Saturday was received. So, I contact the support. Same response. No helpful. Can’t do anything. So, I told them to cancel my order. Still saying , don’t worry. Your order will receive. But I don’t want it anymore because I didn’t trust them anymore. I sent the support and no replied. So, I told them to cancel it and want refund. They said, need to send email to cancel the order. So, I sent the email support again.

Before order cancel , I sent the contact support before chat support at 24. Feb They replied at 25 Feb evening, they told my order marked for cancel. Do you want to cancel or continue shipping. I replied again , YES , I want to cancel.

They didn’t know what happen and what I chat with their support team. All the information may not synchronised each other.

Today 26 Feb, my order status not change and still not get refund yet. Paypal already take out my money. No refund yet. Look like they will do all the process again at next shipment from china. I sent the email about how long I need to wait cancel order and refund money. No response. OK. I can’t do anything for now and just wait their response. If they didn’t response until 28 Feb. They may ship together with 27 Feb sale and other people who order at 21 Feb and got payment error people. Look like trying to get 21 Feb is wasting time for them. Tomorrow Redmi can buy at Starhub.

I understand online selling and customer support is not easy. It’s not my first time with order problem. Microsoft surface , google nexus 4 got the order problem, too. First day , order and payment completed.However, next day , they cancel my order after next day because no more stock. Look like they didn’t connect with stock data and website. However ,they didn’t take my money from my account. They void the transactions. However, I told them before take out my money. But don’t care and no reply my email. Just wait. I hope, they will reply my email soon.