Skip to content

Instantly share code, notes, and snippets.

@jaivikram
jaivikram / tree_data.py
Last active September 5, 2018 04:35
Gist to show and sync data between react-sortable-tree and django-treebeard
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
Recently I tried showing tree data contained in `django-treebeard` in the backend as tree data in `react-sortable-tree` in the frontend.
https://github.com/frontend-collective/react-sortable-tree
https://github.com/django-treebeard/django-treebeard
The idea was to keep the backend updated when the tree nodes are manipulated visually by the user.
@jaivikram
jaivikram / getVideoDetails.py
Last active April 18, 2020 13:02
Python gist to obtain video details like duration, resolution, bitrate, video codec and audio codec, frequency using 'ffmpeg'
#! /usr/bin/env python
import os
import sys
import re
import tempfile
def getVideoDetails(filepath):
tmpf = tempfile.NamedTemporaryFile()
os.system("ffmpeg -i \"%s\" 2> %s" % (filepath, tmpf.name))
lines = tmpf.readlines()