Wednesday, July 19, 2017

TreeSet / ConcurrentSortedList cannot be removed once the value changes

// Check this out.

class KK implements Comparable<KK> {
    public int value;
    public KK(int value) {
        this.value = value;    }

    @Override public int compareTo(KK o) {
        return Integer.compare(value, o.value);    
    }
}

@Testvoid test_treeset() {
    SortedSet<KK> set = new TreeSet<>();    
    KK a = new KK(5);    
    KK b = new KK(10);
    set.add(a);    set.add(b);
    set.forEach(item -> System.out.println(item.value));
    // change b to less than a -> this will not remove the value after b value changes.    
    // because it guranteed log n, so it will not find it.    
    b.value = 4;

    set.remove(b);
    System.out.println("After remove -> it will not remove value");    
    set.forEach(item -> System.out.println(item.value));}

Friday, July 24, 2015

My Quick Git Process

Create your own branch..

commit your changes
  git commit -m "..."

push changes to your backup
  git push backup branch-name

modify your code


commit with amend
  git commit --amend 

push your changes to remote again with force
   git push backup branch-name -f


once finish your feature... and code review...

merge back to master with 1 commit
 git merge master



Wednesday, June 04, 2014

Using Reserve Proxy for your Single Page App to ovoid CORS

There are couple ways to eliminate CORS, but one of my favourite is to setup reserve proxy server.

Here simplest way how to do it.

1. Install ARR
http://www.iis.net/learn/extensions/installing-application-request-routing-(arr)

2. Enable Proxy
IIS > Select your server > Aplication Request Routing > Server Proxy Setting > Check Enable Proxy

3. Add Url Rewrite inside your site web.config.

<configuration>
<system.webServer>
  <rewrite>
    <rules>
        <rule name="Reverse Proxy to API" stopProcessing="true">
            <match url="^api/(.*)" />
            <action type="Rewrite" url="http://some.api/v1/{R:1}" />
        </rule>
    </rules>
</rewrite>
</system.webServer>
</configuration>

4. Done, now when you request /api in your site, it will automatically forward that to http://come.api/v1/

Wednesday, May 21, 2014

angular scroll with animation for accordion mobile

Recently we want to have scroll animation which works with accordion in mobile.
angular-scroll has bugs where it only check the top position instead recheck this every time.

If you have same issue, feel free to try this version.

https://github.com/kkurni/angular-scroll/

https://gist.github.com/kkurni/98e664941ac1c373a3ff

Ps. Thanks to Matt for this.

Tuesday, May 13, 2014

Improve your site click on mobile site


  • disable user-scalable

<meta name="viewport" content="width=device-width, user-scalable=no" />
  • check any css which has heavy performance such as *first-child
  • create grouping by hide and show components, it will your less dom objects.

Friday, May 09, 2014

Debug your services call using fiddler

add this into your web.config

 <system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true">
      <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:6666" usesystemdefault="false">
      </proxy>
    </defaultProxy>
  </system.net>
 

Monday, May 05, 2014

Errorception with angularjs

Easy and simple fix to use errorception with anguljar js.

Just add this code to handle error in angularjs.