Microsoft Visio and infamous Windings font

Another Microsoft misery 😢 😢

This time, I am struggling to handle the bullets in SVG output of my drawing.  What I found is that  MS Visio still uses windings/symbol fonts to make the bullets. Don’t know why? When are they going to change this and start using standard Unicode chars? Can anyone from MS please explains to me why they don’t believe in standardization?

IMHO Please use Unicode everywhere be it HTML generated from Word or Visio etc. 

Thanks for reading!

IE11 issue with “arrow” and “includes” Javascript method and an alternate solution

Again one more Microsoft problem 😢 😢

Yesterday, I  suddenly observed that one part of my newly developed feature was not working in IE11. This is a simple feature which contains two select boxes, user can select the one or multiple items from the first select box and copy to another select box. I have added a kind of logic there which checks before copying if the item(s) to be copied are already in list 2, if true, alert the user and skip copying duplicates. While developing I checked this feature in chrome, Edge and Firefox and all work perfectly!  I couldn’t check in IE11 and that was my mistake as IE is infamous for such issues. While debugging I saw that IE11 was crashing on the places where I have used the functions  => and .include. Actually, the arrow function is not supported in IE 11. You can refer to this compatibility table: https://kangax.github.io/compat-table/es6/ to get an overview of what is supported where and to what extent in a detailed fashion. You may read more on arrow functions at below link: 

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

Check below a small demo which shows the problem and an alternate which solves the IE11 issue.

Demo:

**********************************

JSFiddle (Fails in IE11)

JSFiddle (Works in IE11)

**********************************

Github:

code (Fails in IE11) 

code (Works in IE11) 

 

**********************************

Happy coding!

Perl development journey and books collection

While doing routine cleaning of my personal library I was surprised to see the Perl book collection I have made over the period of time. My Perl dev journey started in a full-fledged manner way back in fall 2007. Prior to that was mainly developing using C, C++, assembly language. My first impression with Perl was not very exciting mainly due to ugly syntax and the way the OO is achieved and being from C++ background initially it was really difficult to grasp. But over the years working with language and while developing a large scale web application I learned a lot of nitty-gritty of the language and still learning…  Today I can vouch for Perl for its speed, portability, great module system CPAN and excellent dedicated community. Thanks to all the module authors and contributors on Perl Monks and StackOverflow. You guys are amazing! 
Now, the books which helped me immensely to wrote better Perl programs.

New coder and Experienced coders

I’ve found that a big difference between new coders and experienced coders is faith: faith that things are going wrong for a logical and discoverable reason, faith that problems are fixable, faith that there is a way to accomplish the goal. The path from “not working” to “working” might not be obvious, but with patience, you can usually find it.

Read the above quote somewhere on medium, myself as a programmer can easily sync with the saying. Have observed this many many times in my coding experience of the last two decades. To add, patience is needed much more while dealing with critical real-time production bugs.

I personally feel that analysis of the problem with a cool head and focus and pateince is is the key to debug and resolve critical problems.

Happy Coding!

Books recommendation series: Predictive analytics

Book

Predictive analytics, The Power to Predict Who will Click, Buy, or Die
Eric Segel
https://www.predictiveanalyticsworld.com/book/

Theme

This book deals with quantitative efforts to predict human behavior. The book focuses on a large number of prediction efforts that are much more successful now than efforts some decade back. This is mainly due to faster computing resources and lots of data availability. During the past decade has been an explosion in computation and information technology. With it has come vast amounts of data in a variety of fields such as medicine, biology, finance, and marketing. As a result, banks, retailers, political campaigns, doctors and hospitals, and many more organizations have been quite successful of late at predicting the behaviors of particular humans. These efforts have been helpful at winning customers, elections, battle with disease etc. The book provides plenty of case studies from above fields.

Takeaway

This is fun to read, a fascinating book as this is not very technical so suitable for all masses. Case studies are very good and give you great insight into predictive analytics.
I highly recommend this book for aspiring Data Scientists/Managers/CEO’s or anyone interested in understanding the science of analystics.

Overall good read. Very much recommeded. I personally liked the topics and case studies on risk and fraud detection very well written and visulized.

Suggestions

  • This is not technical so don’t expect details on ML algorithms etc
  • I found sometimes the case-studies are over-simplified in actual I think they are not that simple while implementing.
  • I found that one can pick a chapter and read, you don’t have to follow the order.
  • Don’t expect that you will learn to do analytics, making a model just by reading this. This book is mainly focussed for non-techies readers. If you are a techie focus more time on ML algorithms and use this book as a part-time bed time read.

Happy reading!



date sorting in datatables using moment js

Sorting dates could be tricky because of various date and time format used. Fortunately there is awsome js lib called moment.js library avaliable, this is free and open source. I have made a small demo of how moment.js is used with datatables. for date sorting. First let have a look into how many date time types which moment.js supports.

Format Dates

moment().format('MMMM Do YYYY, h:mm:ss a'); // March 12th 2019, 6:46:42 pm
moment().format('dddd');                    // Tuesday
moment().format("MMM Do YY");               // Mar 12th 19
moment().format('YYYY [escaped] YYYY');     // 2019 escaped 2019
moment().format();                          // 2019-03-12T18:46:42+05:30
                                            // undefined

Relative Time

moment("20111031", "YYYYMMDD").fromNow(); // 7 years ago
moment("20120620", "YYYYMMDD").fromNow(); // 7 years ago
moment().startOf('day').fromNow();        // 19 hours ago
moment().endOf('day').fromNow();          // in 5 hours
moment().startOf('hour').fromNow();       // an hour ago
                                          // undefined

Calendar Time

moment().subtract(10, 'days').calendar(); // 03/02/2019
moment().subtract(6, 'days').calendar();  // Last Wednesday at 6:46 PM
moment().subtract(3, 'days').calendar();  // Last Saturday at 6:46 PM
moment().subtract(1, 'days').calendar();  // Yesterday at 6:46 PM
moment().calendar();                      // Today at 6:46 PM
moment().add(1, 'days').calendar();       // Tomorrow at 6:46 PM
moment().add(3, 'days').calendar();       // Friday at 6:46 PM
moment().add(10, 'days').calendar();      // 03/22/2019
                                          // undefined

Multiple Locale Support

moment.locale();         // en
moment().format('LT');   // 6:46 PM
moment().format('LTS');  // 6:46:42 PM
moment().format('L');    // 03/12/2019
moment().format('l');    // 3/12/2019
moment().format('LL');   // March 12, 2019
moment().format('ll');   // Mar 12, 2019
moment().format('LLL');  // March 12, 2019 6:46 PM
moment().format('lll');  // Mar 12, 2019 6:46 PM
moment().format('LLLL'); // Tuesday, March 12, 2019 6:46 PM
moment().format('llll'); // Tue, Mar 12, 2019 6:46 PM
                        

I have used the following libs to make this demo:

  • jquery
  • data table
  • moment.js
  • datetime-moment.js

HTML source


<h3 class="ui_title">Employee joining data</h3>
<div class="ui_block">
<table id="myTable1" class="ui_table">
<thead id="table_head">
<tr>
<th style="width:150px;">Name</th>
<th style="width:50px;">Designation</th>
<th>Joining date</th>
</tr>
</thead>
<tbody>
<tr>
	<td>Ram</td>	
	<td>Engineer</td>
	<td>18/10/2015</td>	
</tr>
<tr>
	<td>Shyam</td>	
	<td>Engineer</td>
	<td>05/01/2012</td>	
</tr>
<tr>
	<td>Suresh</td>	
	<td>Sr. Engineer</td>
	<td>22/06/2010</td>	
</tr>
<tr>
	<td>Ahmed</td>	
	<td>Manager</td>
	<td>02/02/2002</td>	
</tr>
<tr>
	<td>Leena</td>	
	<td>Sr. Manager</td>
	<td>01/01/2018</td>	
</tr>
<tr>
	<td>Pradeep</td>	
	<td>Architect</td>
	<td>21/05/2012</td>	
</tr>
</tbody>
</table>
</div>

jQuery

jQuery(document).ready(function() {
$.fn.dataTableExt.oPagination.iFullNumbersShowPages = 3;
$.fn.dataTable.moment('DD/MM/YYYY');
		$("#myTable1").DataTable({	
		"autoWidth": false,
		"destroy": true,
		"order": [[2, 'desc']],
		"pageLength": 15,
		"lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
		"pagingType": "full_numbers"
});
});	

CSS

/* 1. GENERAL */
* {
	font-family: /* 'Roboto', */ Verdana, Arial, Helvetica, sans-serif;
	font-size: 13px;
	box-sizing: border-box;
}

body {
	font-family: /* 'Roboto', */ Verdana, Arial, sans-serif;
	background: #f8f8f8; /* e2dbc5; */
	margin: 1em;
}

.ui_title {
	font-family: /* 'Open Sans', */ Verdana, sans-serif;
	color: #2A3F54;
	font-weight: 400;
	font-size: 24px;
	line-height:26.4px;
	border-bottom: 1px solid  #2A3F54;
}

.ui_title i {
	font-size: 24px;
}

/* BLOCKS */
.ui_block {
	min-width: 20px;
	background: white;
	border: 0; /* 1px solid #ebebeb;*/
	padding: 1em 1em;
	margin-bottom: 2em;
	box-shadow: 0 4px 6px 0 hsla(0,0%,0%,0.2);
}

.ui_block h3,
.ui_block h3 i {
	font-family: /* 'Open Sans', */ Verdana, sans-serif;
	border-bottom: 2px solid rgb(230,233,237);
	color: rgb(115,135,156);
	font-weight: 400;
	font-size: 16px;
	line-height: 18.7px;
	padding: 0;
	margin: 1em 0 0.5em 0;
}
.ui_block h3:first-child {
	margin: 0.5em 0 0.5em 0;
}

/* 3. TABLE */
.ui_table {
	border: 1px solid black;
	border-collapse: collapse;
	width:100%;
	margin-bottom: 1em;
}
.ui_table th {
	text-align: left;
	background: lightgray;
}
.ui_table td,
.ui_table th {
	border: 1px solid gray;
	padding: 3px 5px;
	font-size: 10pt;
	font-weight: 400;
}

Demo

jsFiddle
https://jsfiddle.net/ppant/efL3pvq2/3/
Github
https://github.com/ppant/jshacks/blob/master/data-table-date-sorting.html

References:


git amend scenerios

Sometimes we need to change the commit message of already committed/committed-pushed files. See below some of the scenarios might arise..

Scenerio 1-> Committed but not pushed

$ git commit –amend

This will open an editor with the commit message. If you are using vi editor edit the commit message and save using !wq: Check with $git log if the message has been amended correctly.

Scenerio 2-> Already pushed + most recent commit

It might be the case that if a user has already pushed the changes to git central repository, in this type of scenario we need to first amend the most recent local commit and afterward apply –force push which will forcefully push the changes to the server. In this process, one thing to keep in mind is that if in between any other user who has already synced local copy with the central repository needs to re-pull.

$ git commit –amend
Edit the message in vi and save and exit
$ git push origin <branch_name> –force


Scenerio 3-> Not pushed + old commit

$ git rebase –i HEAD~X

where X is the number of commits to go back then move to the line of your commit, change pick and edit then change your commit message

$ git commit –amend

Finish the rebase with:

$ git rebase –continue

Rebase opened your history and let you pick what to change. With edit, you tell that you want to change the message. Git moves you to a new branch to let you –amend the message. git rebase — continue puts you back in your previous branch with the message changes.

alternatively, you can choose reword instead of edit when rebasing to change the commit directly. Then you can skip the amend and rebase continue. You may check this link from git book for more on this.

Scenerio 4-> Already pushed + old commit
Edit your message with the same 3 steps process as menined in scenerios 2 ( rebase –i, commit –amend, rebase –continue). Then force push the commit

$git push <branch_name> master –force

But! please remember re-pushing your commit after changing it will very likely to prevent others to sync with the repo, if they already pulled a copy. You should first check with them.


References:
https://gist.github.com/nepsilon/156387acf9e1e72d48fa35c4fabef0b4

https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History


jQuery accordion with fontawsome icons

a small imple of jQuery accordion (show/hide blocks)

Accordions (extend/collapse) are useful when you want to toggle between hiding and showing a large amount of content. I have made a small demo using jQuery accordion lib. Check my code at github.

You can also check a live demo here

References and links:
Code: https://github.com/ppant/jshacks

Live jfiddle demo: https://jsfiddle.net/ppant/mk2n9c8t/

jQuery ui web site: https://jqueryui.com/accordion/

Books recommendation series: Elements of statistical learning

Since long I was thinking to write down my recommendation of the books I have read recently or in past as well. The plan is to post atleast one book recommendation weekly.

Check below my first recommendation.

Book

Elements of statistical learning
Hastie, Tibshirani, and Friedman (2009 )
https://web.stanford.edu/~hastie/ElemStatLearn/

Theme

During the past decade has been an explosion in computation and information technology. With it has come vast amounts of data in a variety of fields such as medicine, biology, finance, and marketing. The challenge of understanding these data has led to the development of new tools in the field of statistics and spawned new areas such as data mining, machine learning, and bioinformatics. Many of these tools have common underpinnings but are often expressed with different terminology. This book describes the important ideas in these areas in a common conceptual framework. While the approach is statistical, the emphasis is on concepts rather than mathematics. The book’s coverage is broad, from supervised learning (prediction) to unsupervised learning. The many topics include neural networks, support vector machines, classification trees and boosting–the first comprehensive treatment of this topic in any book. 

Takeaway

It is a rigorous and mathematically dense book on machine learning techniques. It gives a very good explanation of how the correlation between Bias, Variance and Model Complexity works. If you have the mathematical background (calculus, linear algebra etc) this is a very good introduction to Machine Learning and covers most of the MI topics. I can say that it has a nice balance between mathematical concepts and intuitive reasoning.
I highly recommend this book for anyone entering to the field of AI/ML.

Suggestions

  • What this book doesn’t provide? is a pragmatic approach or Hands-on practice.
  • Deep analysis of why a specific method works (but it gives you some intuition about what a method is trying to do)
  • If you are doing self-study and don’t have any background in machine learning or statistics advice to refine your understanding of linear algebra and calculus before reading this book.
  • Free PDF is available but suggest to buy a print book.

Download and purchase link

Buy: https://web.stanford.edu/~hastie/ElemStatLearn/
PDF: https://web.stanford.edu/~hastie/ElemStatLearn/printings/ESLII_print12.pdf



SpaceVim review

As a Vim user for nearly 2 decades, recently I got an opportunity to explore
SpaceVim a new Vim distribution. Some of the features worth highlighting are:

  • Nicely built edit mode.
  • Loved the idea of collecting related plugins together to provide features.
  • Instant search results using grep, ag, rgackpt and with a great UI.

Will exlore more features in coming days and shall update the post.

Gitbub:https://github.com/SpaceVim/SpaceVim