Skip to content

Instantly share code, notes, and snippets.

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

krishnakummar

🏠
Working from home
View GitHub Profile
@krishnakummar
krishnakummar / lines_in_worldgeo.js
Last active April 22, 2020 01:58
Echart helpers
var geoCoordMap = {
'SUNNYVALE': [-122.0144, 37.386],
'BENGALURU': [77.580643, 12.972442],
'US': [-97.822, 37.751],
'SARATOGA': [-122.0230, 37.2638],
'CHENNAI':[80.2707, 13.0827],
'MUMBAI':[72.8777, 19.0760]
};
var PopData = [
[{name:'US'}, {name:'US',value:95}],
@krishnakummar
krishnakummar / create-topology.sh
Created November 17, 2018 09:20
create graphviz block diagram from docker-compose.yml
docker run --rm -it --name dcv -v /home/user/blog:/input pmsipilot/docker-compose-viz render -m image --force docker-compose.yml --output-file=topology.png --no-volumes --no-ports --no-networks
@krishnakummar
krishnakummar / docker-compose.yml
Created November 17, 2018 09:16
Sample docker compose for SaaS
version: '3.4'
services:
rabbitmq:
image: rabbitmq:3-management
ports:
- "15672:15672"
- "5672:5672"
deploy:
replicas: 1
@krishnakummar
krishnakummar / donut-example.py
Created September 11, 2015 11:56
Donut chart using python matplotlib
import matplotlib.pyplot as plt
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0, 0, 0) # explode a slice if required
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True)
@krishnakummar
krishnakummar / medicinenames.py
Created April 17, 2015 14:24
Fetching medicine names from medindia
import requests
import BeautifulSoup
import string
session = requests.session()
alphas = list(string.ascii_uppercase)
for i in alphas:
url_parse = "http://www.medindia.net/drugs/manufacturers.asp?alpha=" + i
req = session.get(url_parse)
doc = BeautifulSoup.BeautifulSoup(req.content)
manufacturers_div = doc.find("div", attrs={"class": "headlines clear-fix"})
@krishnakummar
krishnakummar / mysql_query_export
Created January 28, 2015 12:36
Mysql Query Export
mysql --user=wibble --password wobble -B -e "select * from vehicle_categories;" | sed "s/'/\'/;s/\t/\",\"/g;s/^/\"/;s/$/\"/;s/\n//g" > vehicle_categories.csv
@krishnakummar
krishnakummar / gist:7429310
Created November 12, 2013 11:16
Create a html page to display all the profile images from ssmatri.com. This is for easy viewing. Its boring to click on each and every profile to view their details.
import requests
import BeautifulSoup
fo = open("ossmat.html", "wb")
session = requests.session()
for page in range(1,10):
req = session.get('http://ssmatri.net/setup/ProfileListview.asp?type=GI&sh=1&thisPage='+ str(page))
doc = BeautifulSoup.BeautifulSoup(req.content)
all_td = doc.findAll('tr')
#for x in range(10,20):
@krishnakummar
krishnakummar / gist:7429232
Created November 12, 2013 11:08
removing all thumbnails from mp3 songs folder. these thumbnails are a disturbance when they are added in windows media player. this gist helps u to remove these images through powershell commands
PS> $data = get-childitem . "folder*" -rec -force | select directory, name
PS> foreach($x in $data) { $url = $x.directory.tostring() + '\' + $x.name.tostring(); remove-item $url -force;}
@krishnakummar
krishnakummar / gist:7246580
Created October 31, 2013 09:10
ruby 2.0 and rails 4.0 installation
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar -xzvf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247
autoconf
./configure --program-suffix=19 --enable-shared --with-readline-dir=/usr/local
make
sudo make install
ruby -v
wget http://rubyforge.org/frs/download.php/76729/rubygems-1.8.25.tgz
tar -xzvf rubygems-1.8.25.tgz
@krishnakummar
krishnakummar / datedifference.php
Created June 29, 2011 12:34
Humanize date differences in PHP (like facebook - Eg: 2 days ago, 14 hours ago, few seconds ago).
#!/usr/bin/env php
# This function prints the difference between two php datetime objects
# in a more human readable form
# inputs should be like strtotime($date)
# Adapted from https://gist.github.com/207624 python version
function humanizeDateDiffference($now,$otherDate=null,$offset=null){
if($otherDate != null){
$offset = $now - $otherDate;
}