Skip to content

Instantly share code, notes, and snippets.

View mr-karan's full-sized avatar
🎯
Focusing

Karan Sharma mr-karan

🎯
Focusing
View GitHub Profile
@mr-karan
mr-karan / docker-networks.md
Last active March 27, 2019 17:28
docker networks simple explanation

This is a simple docker-compose file. It creates 2 running instances of image (containers) from redis and postgres. Exposes port 9379 for redis and port 9432 for postgres on your local machine

I created a network called backend. You can check ip addr and see the newly created network. The way it works is that, both containers will be on same network bridge. Think of it like a VLAN? network basically does a lot of things behind the scenes, but most importantly it lets you access the other container through the service name defined in docker-compose file. From your redis, if you want to access postgres 5432 port, you can do using db:5432. So host is not localhost it is db. db internally resolves to the private ip of the network interface you saw in ip addr when you created backend network. docker has created an entry in /etc/resolv.conf which is 127.0.0.11. It is an internal dns namesever running in your docker daemon, which resolves all the containers' service name to their privat

@mr-karan
mr-karan / csv_split.py
Last active September 11, 2018 08:25
Python Function to Split CSV File with headers
# coding: utf-8
import csv
import os
from itertools import tee, islice
LINES_SPLIT = 1000
def chunks(l, n):
@mr-karan
mr-karan / orderbook.md
Last active November 12, 2017 05:54
Orderbook example

Orderbook

Bid Ask
'''
Sample comment
'''

var x=4;
@mr-karan
mr-karan / file
Created February 19, 2017 06:10
freedom_public
{"0.8702211885003204":"-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nCharset: UTF-8\r\n\r\nxv8AAABSBAAAAAATCCqGSM49AwEHAgME/Tulb4VMvOMsdGeem0HkJ6n+ZIKYTVeY\r\n1w3/1ZZvM923GxWQJy5Xv1yCW1/CaHNHGNcMV5ymvpyp/QyeE43hJs3/AAAACDxn\r\naXRodWI+wv8AAACOBBATCABA/wAAAAWCWKk2z/8AAAACiwn/AAAACZBeR0WTc44z\r\nSv8AAAAFlQgJCgv/AAAABJYDAQL/AAAAApsD/wAAAAKeAQAApIAA/ipDe+m4RAU5\r\nTwSgxeWXjCPk0MEUAnxjJp5gVI71CRUuAQCF6djdccBIkTCPP94QnFRw1LjrlzNL\r\n6yRNtUaDCf3nV87/AAAAVgQAAAAAEggqhkjOPQMBBwIDBBinQNHCCioTpdaNjpDT\r\nFm4+BjKNoffwawQDT4uMwm5XoTkhbzPkjkhg84VQPNJMiYUYb9puajG2V2/Qoegi\r\nzBoDAQgHwv8AAABtBBgTCAAf/wAAAAWCWKk2z/8AAAAJkF5HRZNzjjNK/wAAAAKb\r\nDAAAPC4BALzQEQAZA3s6wUMtWqwcsMVJ9JS+cEqfJtn7wjOXy8CHAQCv2Nz3rwVt\r\n406ybzAr5P28KSMTOIz8UFytjPYb7L6Pjw==\r\n=3M1q\r\n-----END PGP PUBLIC KEY BLOCK-----\r\n"}
### Keybase proof
I hereby claim:
* I am mr-karan on github.
* I am mrkaran (https://keybase.io/mrkaran) on keybase.
* I have a public key whose fingerprint is CC91 6602 7F75 21FB 117A 90C4 06BD 5EE8 C167 6946
To claim this, I am signing this object:
import paramiko
ip='server ip'
port=22
username='username'
password='password'
cmd='some useful command'
ssh=paramiko.SSHClient()
@mr-karan
mr-karan / workGSoC.md
Last active November 3, 2016 07:39
work summary

Work Summary

LInk to Issue Link to PR Description Status
#1925 #2569 Syntax Highlighting Merged
#154 #2 coala_bears_create Merged
- #2 Bear Docs Website Merged
#31 #443 GoErrCheckBear Merged
#400 #415 VerilogLintBear Merged
#573 [#581](h
class Node(object):
def __init__(self,val=None,curMax=None):
self.val = val
self.curMax = curMax
def __repr__(self):
return str(self.data)
class Stack(object):
def __init__(self):
@mr-karan
mr-karan / coala_asciinema_urls.py
Last active August 6, 2016 10:46
script to get all asciinema urls from @coala_analyzer twitter
# Quick script to download all asciinema URLs from @coala_analyzer
import tweepy
import os
#Twitter API credentials
consumer_token = os.environ['consumer_token']
consumer_secret = os.environ['consumer_secret']
access_token = os.environ['access_token']
access_secret = os.environ['access_secret']