This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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; |