Skip to content

Instantly share code, notes, and snippets.

View ManasJayanth's full-sized avatar

prometheansacrifice ManasJayanth

View GitHub Profile
1. Install all the package dependecies
$ sudo npm install -d
2. Build the source using grunt
$ grunt build
@ManasJayanth
ManasJayanth / gist:7540773
Last active December 28, 2015 18:09
Code for StackOverflow question (http://stackoverflow.com/questions/20063968/xml-get-attributes-javascript-doesnt-work-on-childnodes) - xml get attributes javascript doesn't work on childNodes
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","maps/kmap.svg",false);
xmlhttp.send();
var countries_data = {"type":"FeatureCollection","features":[
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[74.92,37.24],[74.57,37.03],[72.56,36.82],[71.24,36.13],[71.65,35.42],[71.08,34.06],[69.91,34.04],[70.33,33.33],[69.51,33.03],[69.33,31.94],[66.72,31.21],[66.26,29.85],[62.48,29.41],[60.87,29.86],[61.85,31.02],[60.84,31.5],[60.58,33.07],[60.94,33.52],[60.51,34.14],[61.28,35.61],[62.72,35.25],[63.12,35.86],[64.5,36.28],[64.8,37.12],[66.54,37.37],[67.78,37.19],[69.32,37.12],[70.97,38.47],[71.59,37.9],[71.68,36.68],[73.31,37.46],[74.92,37.24]]]]},"properties":{"name":"Afghanistan"},"id":"AF"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[19.44,41.02],[19.37,41.85],[19.65,42.62],[20.07,42.56],[20.59,41.88],[20.82,40.91],[20.98,40.86],[20.01,39.69],[19.29,40.42],[19.44,41.02]]]]},"properties":{"name":"Albania"},"id":"AL"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[2.96,36.8],[8.62,36.94],[8.18,36.52],[8.25,34.64],[7.49,33.89],[9.06,3
@ManasJayanth
ManasJayanth / gist:7862226
Created December 8, 2013 18:59
SVG to illustrate different combinations of sweep and long arc values
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SVG</title>
</head>
<body>
<div class="container" id="viz-container">
<svg width="320" height="400">
<path d="M220,300 A90,80 0 0,0 140,200"
@ManasJayanth
ManasJayanth / gist:7862559
Created December 8, 2013 19:21
SVG to illustrate different orientations of elliptical curves
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SVG</title>
</head>
<body>
<div class="container" id="viz-container">
<svg width="320" height="400">
<path d="M139,199 A90,80 0 1,0 140,200"
@ManasJayanth
ManasJayanth / limit-cowsay.bash
Last active August 29, 2015 13:58
Bash script to limit the number of times fortune-cowsay message is displayed at terminal start up
# Checking dependencies
command -v fortune >/dev/null 2>&1 ||
{ echo >&2 "I require fortune but it's not installed. Aborting."; exit 1; }
command -v cowsay >/dev/null 2>&1 ||
{ echo >&2 "I require cowsay too, but it's not installed. Aborting."; exit 1; }
# Set your counter limit here
COUNTER_LIMIT=7
@ManasJayanth
ManasJayanth / formatted-string.js
Last active August 29, 2015 14:03
Javascript alternative for ruby, python's formatted string
/**
* Formatted string in javascript
*/
function renderTemplate (template, obj) {
return template.replace(/\{\{[a-zA-Z]+\}\}/g, function (m) {
for (var key in obj) {
if (m.indexOf(key) !== -1) {
return obj[key];
}
@ManasJayanth
ManasJayanth / gist:62f3e6fae2161b829723
Last active August 29, 2015 14:07
Hand compile bash with Shellshock fix (Source: https://news.ycombinator.com/item?id=8364385)
#assume that your sources are in /src
cd /src
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
#download all patches
for i in $(seq -f "%03g" 0 25); do
wget http://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$i;
done
if(typeof escapeHtmlEntities == 'undefined') {
escapeHtmlEntities = function (text) {
return text.replace(/[\u00A0-\u2666<>\&]/g, function(c) {
return '&' +
(escapeHtmlEntities.entityTable[c.charCodeAt(0)] || '#'+c.charCodeAt(0)) + ';';
});
};
// all HTML4 entities as defined here: http://www.w3.org/TR/html4/sgml/entities.html
// added: amp, lt, gt, quot and apos
function scrollTo(Y, duration, easingFunction, callback) {
var start = Date.now(),
elem = document.documentElement.scrollTop?document.documentElement:document.body,
from = elem.scrollTop;
if(from === Y) {
callback();
return; /* Prevent scrolling to the Y point if already there */
}