Skip to content

Instantly share code, notes, and snippets.

View kirankotari's full-sized avatar
:octocat:
Coming back up-to speed, need a bit more time.

Kiran Kumar Kotari kirankotari

:octocat:
Coming back up-to speed, need a bit more time.
View GitHub Profile
@kirankotari
kirankotari / emailer.py
Created May 16, 2016 04:28 — forked from sarahholderness/emailer.py
Python scripts to read a list of customer emails and send an email with the daily weather forecast
import weather
import smtp
'''
Send a greeting email to our customer email list
with the daily weather forecast and schedule
'''
def get_emails():
# Reading emails from a file
@kirankotari
kirankotari / vagrant-cheat-sheet.md
Created February 12, 2019 16:30 — forked from wpscholar/vagrant-cheat-sheet.md
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
#!/bin/bash
echo 'Starting Provision: web'$1
sudo apt-get update
sudo apt-get install -y nginx
echo "<h1>Machine: web"$1"</h1>" >> /usr/share/nginx/html/index.html
echo 'Provision web'$1 'complete'
#!/bin/bash
echo 'Starting Provision: lb1'
sudo apt-get update
sudo apt-get install -y nginx
sudo service nginx stop
sudo rm -rf /etc/nginx/sites-enabled/default
sudo touch /etc/nginx/sites-enabled/default
echo "upstream testapp {
server 10.0.0.11;
@kirankotari
kirankotari / m220p_shell.sh
Last active February 20, 2019 19:43
M220P: MongoDB for Python Developers Env. setup
#!/bin/bash
echo 'Starting Provision: M220P Development Environment'
sudo apt-get update
sudo apt-get install -y git
curl https://pyenv.run | bash
sudo echo PATH="~/.pyenv/bin:$PATH" >> ~/.bash_profile
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
source ~/.bash_profile
@kirankotari
kirankotari / mongodb_shell.sh
Created February 20, 2019 19:38
M220P: MongoDB for Python Developers DB setup
#!/bin/bash
echo 'Starting Provision: DB'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
@kirankotari
kirankotari / M220P_Vagrantfile
Created February 20, 2019 19:40
M220P: MongoDB for Python Developers
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define "mongodb" do |mongodb|
mongodb.vm.box = "ubuntu/trusty64"
mongodb.vm.box_check_update = false
mongodb.vm.network "private_network", ip: "192.168.27.71"
mongodb.vm.provider "virtual_box" do |vb|
# Reading csv file data in general..!
import time
path = '../input/mean/csv/data2.csv'
start = time.perf_counter()
data = []
for line in open(path):
row = []
for col in line.strip().split(','):
if col:
row.append(float(col))
@kirankotari
kirankotari / in-place-merge-sort.py
Created April 17, 2019 12:24 — forked from m00nlight/gist:a076d3995406ca92acd6
Python merge sort in place, so space complexity is O(1)
import random
def merge_sort(xs):
"""Inplace merge sort of array without recursive. The basic idea
is to avoid the recursive call while using iterative solution.
The algorithm first merge chunk of length of 2, then merge chunks
of length 4, then 8, 16, .... , until 2^k where 2^k is large than
the length of the array
"""
gource
--title "Kiran Kumar - Project contribution"
-s .6
--highlight-user "Kiran Kumar"
--file-idle-time 0
--start-date "2018-11-01 00:00:00 +5"
--stop-date "2019-03-26 00:00:00 +5"
--loop
--follow-user "Kiran Kumar"
--hide filenames,mouse,progress