Skip to content

Instantly share code, notes, and snippets.

View manojkarthick's full-sized avatar
powered by caffeine

Manoj Karthick manojkarthick

powered by caffeine
View GitHub Profile
def _get_dict(self, obj):
for attr, value in obj.__dict__.items():
self.__dict__[attr] = value
def _set_attributes(self, model):
if model:
self._get_dict(model)
@manojkarthick
manojkarthick / example_topic_list.py
Last active April 15, 2018 20:13
Example for using show_topic_list in gensim.ldamodel
import gensim
import os
import re
import pandas as pd
path = "mkbhd.txt" # Your filename here
texts = []
all_prob = []
all_topics = []
@manojkarthick
manojkarthick / Dockerfile
Created November 26, 2018 09:56
Run python application using miniconda + docker
# using miniconda3 since requirements contains scipy toolkit packages
FROM continuumio/miniconda3:latest
RUN mkdir -p /app
WORKDIR /app
# copy requirements into app folder
COPY requirements.txt /app
@manojkarthick
manojkarthick / Dockerfile
Created November 26, 2018 10:02
Docker multi-stage builds for python applications
# Advantage of multi-stage builds:
# --------------------------------
# pycrypto needs gcc and other deps
# as it is compiled during install.
# using a smaller dist image like alpine,
# we don't pay the penalty of a fat image
# Our development(base) image
FROM python:3 as python-base
@manojkarthick
manojkarthick / autocomplete-kubectl
Created November 26, 2018 10:05
Enabling autocomplete for kubectl on zsh
# Add to .zshrc
# Kubectl auto-completion
if [ $commands[kubectl] ]; then
source <(kubectl completion zsh)
fi
@manojkarthick
manojkarthick / Dockerfile
Created November 26, 2018 10:07
Creating jekyll docker with preinstalled dependencies
FROM ruby:2.5-alpine
# Install C dependencies and Jekyll
RUN apk add --no-cache build-base gcc bash cmake
RUN gem install jekyll
# Building with Gems installed to eliminate bundle installation every time
WORKDIR /site
COPY Gemfile .
@manojkarthick
manojkarthick / purge_cloudflare.py
Last active November 26, 2018 10:11
Purge cloudflare cache
import requests
headers = {
'X-Auth-Email': '<email>',
'X-Auth-Key' : '<secret auth key>',
'Content-Type': 'application/json',
}
data = '{"purge_everything":true}'
@manojkarthick
manojkarthick / subset.py
Created November 26, 2018 10:27
Get subset of key-values from a dictionary
def select_keys(bigdict):
"""
Return a dictionary that contains only a subset of
the keys referenced by the `wanted_keys` list
:param bigdict: dictionary containing all the keys
:type bigdict: dict
:returns: subset of the dictionary
:rtype: dict
"""
@manojkarthick
manojkarthick / minikube-hyperkit.sh
Created November 26, 2018 10:42
Use Hyperkit with minikube instead of virtualbox
#!/bin/bash
# Works with:
# Docker 18.06.1-ce, build e68fc7a
# Kubernetes v1.10.0
# minikube v0.30.0
# Download minikube hyperkit driver and install
curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-hyperkit \

Keybase proof

I hereby claim:

  • I am manojkarthick on github.
  • I am manojkarthick (https://keybase.io/manojkarthick) on keybase.
  • I have a public key ASA3FWG-jhUvFQbSjKD-ozXDcmm80uZD3XIyOgDVUT1e1go

To claim this, I am signing this object: