Skip to content

Instantly share code, notes, and snippets.

View kodekracker's full-sized avatar
🎯
Focusing

Akshay Pratap Singh kodekracker

🎯
Focusing
View GitHub Profile
@kodekracker
kodekracker / start-hadoop.sh
Created May 8, 2015 20:27
A script to start Cloudera Hadoop with YARN
#!/usr/bin/env bash
# start YARN
sudo service hadoop-yarn-resourcemanager start
sudo service hadoop-yarn-nodemanager start
sudo service hadoop-mapreduce-historyserver start
# start Hadoop
for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x start ; done
@kodekracker
kodekracker / stop-hadoop.sh
Created May 8, 2015 20:28
A script to stop Cloudera Hadoop with YARN
#!/usr/bin/env bash
# stop YARN
sudo service hadoop-yarn-resourcemanager stop
sudo service hadoop-yarn-nodemanager stop
sudo service hadoop-mapreduce-historyserver stop
# stop Hadoop
for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x stop ; done
@kodekracker
kodekracker / ipynbTopy
Created May 14, 2015 03:16
This script convert ipython notebook file to python file i.e ( .ipynb -> .py)
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import argparse
import textwrap
import json
import traceback
def createParser():
@kodekracker
kodekracker / github-markdown-style.css
Created May 24, 2015 09:38
A css file for github look alike markdown.
body {
width: 45em;
border: 1px solid #ddd;
outline: 1300px solid #fff;
margin: 16px auto;
}
body .markdown-body
{
@kodekracker
kodekracker / settings.py
Last active January 12, 2017 11:04
A file contains settings required to setup mongoengine (http://mongoengine.org/) in Django Project
# import module
import mongoengine
# Django Database settings
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.dummy',
},
}
# MongoEngine Settings
@kodekracker
kodekracker / settings.py
Created July 16, 2015 08:40
A file contains settings required to config MongoDb Engine (https://github.com/django-nonrel/mongodb-engine) with Django-nonrel (https://github.com/django-nonrel/django)
# Django Database settings
DATABASES = {
'default': {
'ENGINE': 'django_mongodb_engine',
'NAME': 'db-name',
'USER': 'admin',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '27017',
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# 1) Write a program to illustrate recursion for the following:
# * Whether a word is a pallindrome or not.
def isWordPalindrome(word):
"""
Checks whether a word is palindrome or not
"""
@kodekracker
kodekracker / extract-event-information.py
Last active September 9, 2015 07:33
Extract information from URL of event
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import re
def split(delimiters, string, maxsplit=0):
"""
Split string with multiple delimiters
delimiters: a list of delimiters
string: a target string
@kodekracker
kodekracker / gunicorn.py
Created September 10, 2015 07:47
A config file of gunicorn(http://gunicorn.org/) contains fundamental configuration.
# -*- coding: utf-8 -*-
# Gunicorn(v19.3) Configuration File
# Reference - http://docs.gunicorn.org/en/19.3/settings.html
#
# To run gunicorn by using this config, run gunicorn by passing
# config file path, ex:
#
# $ gunicorn --config=gunicorn.py MODULE_NAME:VARIABLE_NAME
#
@kodekracker
kodekracker / json_encoder.py
Last active November 20, 2018 12:36
A Custom SqlAlchemy JSON encoder class to encode models instances in json format which supports major object instances useful in developing api's in flask.
# To use this custom JsonEncoder class, you have to create a __json__() named
# function in each sqlalchemy model class, which basically return a list of model
# class attributes to be parsed, otherwise all attributes are processed present
# in `dir(class_name)`.
#
# Model Example:
# class User(db.Model):
# id = db.Column(db.Integer, primary_key=True)
# name = db.Column(db.String(100))
# email = db.Column(db.String(100))