Skip to content

Instantly share code, notes, and snippets.

View SehgalDivij's full-sized avatar
💭
I may be slow to respond. I will, though.

Divij Sehgal SehgalDivij

💭
I may be slow to respond. I will, though.
View GitHub Profile
@SehgalDivij
SehgalDivij / ffmpeg_install.md
Created January 8, 2019 21:18 — forked from jmsaavedra/ffmpeg_install.md
Install FFmpeg on a Linux Box

###Install FFmpeg via CLI on Linux box

These steps walk through installing a static binary of any ffmpeg version on to your linux machine. If you want to compile from source, there are several ways to do so. Here's the official guide. Tested and works on an AWS EC2 Ubuntu instance, but should work on any Linux machine.

  • SSH into your instance and become root
@SehgalDivij
SehgalDivij / Dockerfile
Created March 2, 2018 18:27
An ideal way of installing dependencies while building a container Using a Dockerfile. Store dependencies in a file, copy it and then RUN install on that from within the related Dockerfile.
FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /config
ADD /requirements.txt /config/
RUN pip install -r config/requirements.txt;
RUN mkdir /src;
# Create Log Directories
RUN mkdir /logs;
RUN mkdir /logs/rest_api;
# Create Log File Placeholders: dev and prod.
@SehgalDivij
SehgalDivij / config.xml
Last active January 21, 2018 06:53
Jenkins Configuration file for the demo project used at Python Pune Meetup
<!--
To use this configuration, do the following:
1. Create a Jenkins Project.
2. Go to the root directory of the configuration. (Linux - /var/lib/jenkins/jobs/<project name>/)
3. Replace the contents of the config.xml file with the contents of this gist, keeping whatever you need and replacing whatever you want to replace.
This should reflect the new configuration in the Jenkins configure section, if the configuration file is valid after copying.
-->
<?xml version="1.0" encoding="UTF-8"?>
<project>
@SehgalDivij
SehgalDivij / MultiLabelColumnEncoder.py
Created December 26, 2017 18:15
Custom Encoder to convert Encode multilple columns of a dataset at once
"""
This snippet is not mine. It has simply been taken from a StackOverflow Answer by PriceHardman in the following link.
(Scroll one answer up from the answer this link takes you to)
https://stackoverflow.com/questions/24458645/label-encoding-across-multiple-columns-in-scikit-learn#31939145
To future me and anyone who comes across this:
- Run this on the entire dataset before splitting the dataset for consistency in the encodings.
"""
from sklearn.preprocessing import LabelEncoder
@SehgalDivij
SehgalDivij / workbook_to_dictionary.py
Created December 22, 2017 09:31
Convert an excel workbook to a dictionary using python's xlrd module
import xlrd
def make_json_from_data(column_names, row_data):
"""
take column names and row info and merge into a single json object.
:param data:
:param json:
:return:
"""
row_list = []
for item in row_data:
@SehgalDivij
SehgalDivij / find_dependents.sh
Created November 16, 2017 16:34
Code to find dependants of a docker image(replace 8df1da2a0a84 with relevant image id)
for i in $(docker images -q)
do
docker history $i | grep -q f50f9524513f && echo $i
done | sort -u
@SehgalDivij
SehgalDivij / middleware.py
Last active December 21, 2023 11:34
Middleware in django to log all requests and responses(Inspired by another Github gist I cannot find the link to, now)
"""
Middleware to log all requests and responses.
Uses a logger configured by the name of django.request
to log all requests and responses according to configuration
specified for django.request.
"""
# import json
import logging
from django.utils.deprecation import MiddlewareMixin