Skip to content

Instantly share code, notes, and snippets.

Muthukrishnan muthuspark

View GitHub Profile
View Simple K-Means from scratch using Python
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.datasets.samples_generator import make_blobs
class K_Means:
def __init__(self, k=3, max_iterations = 500):
self.k = k
muthuspark / gist:f43b08251cd0ec813dfd75823a644fff
Created Feb 27, 2018
List all the files in AWS bucket nodejs
View gist:f43b08251cd0ec813dfd75823a644fff
var AWS = require('aws-sdk');
accessKeyId: "ACCESS_KEY",
secretAccessKey: "SECRET_ACCESS_KEY"
// Create an S3 client
var s3 = new AWS.S3();
muthuspark / gist:5949e24fe19feb0c363677385185538a
Created Sep 1, 2017
Node JS based code to upload folders into AWS S3 using aws-sdk
View gist:5949e24fe19feb0c363677385185538a
var q = require('q');
var AWS = require('aws-sdk');
accessKeyId: "131231",
secretAccessKey: "23135124"
// Create an S3 client
var s3 = new AWS.S3();
muthuspark / gist:a2be62f9c1ee63202bd708a9ccbb383f
Last active Jul 25, 2017
Using node.js as a simple web server
View gist:a2be62f9c1ee63202bd708a9ccbb383f
Install connect and serve-static with NPM
$ npm install connect serve-static
Create server.js file with this content:
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8080, function(){
console.log('Server running on 8080...');
muthuspark / restify
Last active Mar 23, 2017
Basic Rest using Restify
View restify
var restify = require('restify');
var server = restify.createServer();
function corsHandler(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Origin, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-Response-Time, X-PINGOTHER, X-CSRF-Token,Authorization');
res.setHeader('Access-Control-Allow-Methods', '*');
res.setHeader('Access-Control-Expose-Headers', 'X-Api-Version, X-Request-Id, X-Response-Time');
View get url parameters
if ( {
var qs ='+').join(' ');
var params = {},
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
muthuspark / flask-upload
Created Jan 21, 2017 — forked from dAnjou/flask-upload
Flask upload example
View flask-upload
<VirtualHost *>
WSGIDaemonProcess www user=max group=max threads=5
WSGIScriptAlias / /home/max/Projekte/flask-upload/flask-upload.wsgi
<Directory /home/max/Projekte/flask-upload>
WSGIProcessGroup www
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
muthuspark / find-best-time-to-leave-office
Created Jan 3, 2017
To Find the best time to leave my office. The coordinates are the routes from my office to home. The code runs and collects time to reach at regular intervals of 7 mins and stores. I will analyze the data later
View find-best-time-to-leave-office
var request = require('request');
var schedule = require('node-schedule');
var firebase = require('firebase');
var app = firebase.initializeApp({
apiKey: "AIzaSyB1mr1VzndsFlKzNLHLlVtMKmOTXaUAM94",
authDomain: "",
databaseURL: "",
storageBucket: "",
messagingSenderId: "302372771732"
muthuspark / gist:dde82808871897df5b2319546fb8d0f5
Created Dec 2, 2016
Install specific version of nodejs in ubuntu
View gist:dde82808871897df5b2319546fb8d0f5
sudo apt-get install curl
curl --silent --location | sudo bash -
sudo apt-get install nodejs
muthuspark / gist:444c5f16c8b7c8da20913ca93b64161c
Created Nov 23, 2016
Copy files from remote machine to local using SCP
View gist:444c5f16c8b7c8da20913ca93b64161c
scp -i admin.pem admins@ /opt/
You can’t perform that action at this time.