Have been using Alfred primarily for “any” search in macOS, and found Listary for Windows.
software
Software Architecture Patterns
Thanks Oreilly for the free eBook.
Read the description or download the eBook here.
Java Runtime Class Reload
Some call it hot deploy, some refer to runtime class reload/redefine, but whatsoever….
It is just mechanism to reload compiled class file during jvm runtime, to avoid ordinary java development life cycle of “code change -> build -> deploy”, which will significantly save lot’s of wait time (especially when you have multiple modules dependency project).
Both open source project: HotSwapAgent and Spring-Loaded works pretty well for me, but if you are looking for commercial product, JRebel will be the choice.
Windows Multiple Tab Terminal
I have been using Cygwin quite sometime for my development task before ubuntu bash on Windows. Even Windows can group similar program into single task bar icon but open different type of console still occupying task bar spaces and most importantly, it doesn’t look nice since all of them are console for me.
so I use Console to manage it.
Everything working fine except it cannot maximize by clicking on the top right maximize icon, until I found ConEmu which solve my problem and I’m start using it from now on. Of course maximize the windows is just one of the highlight here and many more configuration is available.
If you notice from the image, I open Ubuntu Bash, PowerShell, Cygwin, Git Bash and Command Prompt in different tab 🙂
Convert SVG Into Data URI
Playground available @ Plunker.
Resource: canvg, HTMLCanvasElement
Note: If your browser does not able to launch the Plunker sample, it might due to back-ticks (`) which I’m using for svg string concatenation, it’s ES6 feature and some browser does not support yet. Replace your properly formatted svg will do 🙂
Refused to get unsafe header “Content-Disposition”
Hit into this error when tying to get the “Content-Disposition” header using XMLHttpRequest.
Refused to get unsafe header "Content-Disposition"
Finally found the solution is to include CORS access control headers in HTTP response….
httpResponse.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
Take note that it’s not Access-Control-Allow-Headers but Access-Control-Expose-Headers
Credit to this stackoverflow post.
Business Hour Format
I’m creating a form which allow user to key in multiple days of week with multiple operation hours.
I want the format to save as below, but I found it tedious to reformat for displaying using normal javascript. Look into lodash and found it very handy 🙂
[
{"day":"Mo","hour":{"from":"10am", "to":"2pm"}},
{"day":"Mo","hour":{"from":"3pm", "to":"9pm"}},
{"day":"Th","hour":{"from":"10am", "to":"2pm"}},
{"day":"Th","hour":{"from":"3pm", "to":"9pm"}},
{"day":"We","hour":{"from":"10am", "to":"2pm"}},
{"day":"We","hour":{"from":"4pm", "to":"10pm"}},
];
Format to display:
Mo, Th, We : 10am-2pm Mo, Th : 3pm-9pm We : 4pm-10pm
Plunker here
Reference: schema.org
Disable WebView Application Being Pull Up and Down
I’ve created a hybrid app using Cordova, and notice I’m able to pull the header down and footer up, which lead to weird behaviour when using the app (at least I feel so).
Adding single line of configuration in config.xml solve the issue. (pheeew… spend couple of hours to research this)
<preference name="DisallowOverscroll" value="true"/>
Reference: http://cordova.apache.org/docs/en/6.x/config_ref/index.html
Test Driven Development
Just finished Test-Driven Java Development (but will take longer time to digest), and notice there are few tools/framework worth to share.
Test Driven Development Framework
| Unit Test | Code Coverage | Mocking |
| JUnit | JaCoCo (Java Code Coverage)) | Mockito |
| TestNG | EasyMock | |
| Hamcrest | PowerMock | |
| AssertJ |
Behavior Driven Development Framework
| Web Testing |
RESTful API Testing |
| Selenide | REST Assured |
| JBehave | |
| Cucumber |
Overall this is quite a good book if you practice TDD, as it include bunch of hands on tutorial. Personally I think practicing TDD is good if we have solid requirement (or at least not changing every few days), else we will waste a lot of time just to maintain unit test for immature requirement 🙂
Yet Another Cleaner Way To Construct CSV String in Java
Accidentally found this util class while reading an ebook, and think it worth sharing since myself always found this a tedious code especially prefix and suffix the string.
We used to construct CSV string as below:
StringBuilder nameCsv = new StringBuilder();
nameCsv.append("Maria").append(",");
nameCsv.append("Ken").append(",");
nameCsv.append("Collin");
System.out.println(nameCsv.toString());
//OUTPUT: Maria,Ken,Collin
With new StringJoiner util in Java 1.8, we can do it in a cleaner way.
StringJoiner nameCsv = new StringJoiner(",");
nameCsv.add("Maria");
nameCsv.add("Ken");
nameCsv.add("Collin");
System.out.println(nameCsv.toString());
//OUTPUT: Maria,Ken,Collin
The constructor also allow us to prefix and suffix the string.
StringJoiner nameCsv = new StringJoiner(",", "{", "}");
nameCsv.add("Maria");
nameCsv.add("Ken");
nameCsv.add("Collin");
System.out.println(nameCsv.toString());
//OUTPUT: {Maria,Ken,Collin}









