This basically discard all changes, commits, etc. which are not pushed to remote yet, and pull the latest version from the remote.
git fetch origin master
git reset --hard FETCH_HEAD
git clean -df
function showmethemoney(asjson) { | |
var a = ga.getAll(); | |
a.forEach(function(g) { | |
var json = { | |
gid: g.get('_gid'), | |
trackingId: g.get('trackingId'), | |
clientId: g.get('clientId'), | |
cookieDomain: g.get('cookieDomain'), | |
location: g.get('location'), | |
data: JSON.parse(JSON.stringify(g.b.data.values)) |
You want to have a look at LoDash
or Underscore
or Slugify
for more reliable version. This is just for fun, and probably might not suitable for any production use 🤓
So, I wanted to kebabCase
a string
literal without having to refer any of the aboves. After reading few js libraries mentioned above, this is what I ended up.
function kebabCase(value, separator = '_') {
// Expression to trim trailings
var defaultToWS = '[' + separator.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') + ']';
function ifGrade(marks) { | |
if (marks > 100) return 'Cheating is bad!'; | |
else if (marks >= 90) return 'A+'; | |
else if (marks >= 80) return 'A'; | |
else if (marks >= 70) return 'B+'; | |
else if (marks >= 60) return 'B'; | |
else if (marks >= 50) return 'C'; | |
else if (marks >= 40) return 'D'; | |
else return 'F'; | |
} |