Skip to content

Instantly share code, notes, and snippets.

View kishorpawar's full-sized avatar
🏠
Working from home

Kishor Pawar kishorpawar

🏠
Working from home
View GitHub Profile
// This function converts UTC date string to browser's time zone.
// and returns locale formatted date.
function toUserTimezone(utcDate){   
timezoneOffset = new Date().getTimezoneOffset() * -1;   
tojsDateObj = new Date(utcDate);   
convertedDate = new Date(tojsDateObj.getTime() + (timezoneOffset * 60000));   
return convertedDate.toLocaleString();
}
// this function coverts browser's zone specific dates to UTC timezone.
/***
Please test this in browser by disabling web security to avoid CORS issues.
***/
let Analyse = class
{
let bigtext_url = "http://norvig.com/big.txt";
let lookup_url = "https://dictionary.yandex.net/api/v1/dicservice.json/lookup"
let api_key = "dict.1.1.20170610T055246Z.0f11bdc42e7b693a.eefbde961e10106a4efa7d852287caa49ecc68cf"
@kishorpawar
kishorpawar / install-git-completion.sh
Last active January 27, 2018 18:18 — forked from johngibb/install-git-completion.sh
Mac OS X - Install Git Completion
URL="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash"
PROFILE="$HOME/.profile"
echo "Downloading git-completion..."
if ! curl -L "$URL" --silent --output "$HOME/.git-completion.bash"; then
echo "ERROR: Couldn't download completion script. Make sure you have a working internet connection." && exit 1
fi
@kishorpawar
kishorpawar / array_sort.js
Created March 20, 2017 17:35
Sorting array of objects in javascript
/*
* Using and overriding array's sort function
*/
var sort_by_age = function(arr, key, order="asc")
{
return arr.sort(function(elem, elem2){
result = (elem[key] < elem2[key]) ? -1 : (elem[key] > elem2[key] ? 1 : 0 );
if(order == "asc")
return result;