Skip to content

Instantly share code, notes, and snippets.

@maciakl
maciakl / gist:5033614
Created February 25, 2013 21:44
Windows batch files - date and time formatting:
@echo off
rem System provided date and time
echo %DATE%
echo %TIME%
rem Capture Hour
set hour=%time:~0,2%
rem Remove leading space if single digit
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
@silentsokolov
silentsokolov / get_youtube_id.py
Last active November 9, 2023 22:16
Python: get youtube id
# Get youtube id
#http://youtu.be/5Y6HSHwhVlY
#http://www.youtube.com/embed/5Y6HSHwhVlY?rel=0
#http://www.youtube.com/watch?v=ZFqlHhCNBOI
regex = re.compile(r'(https?://)?(www\.)?(youtube|youtu|youtube-nocookie)\.(com|be)/(watch\?v=|embed/|v/|.+\?v=)?(?P<id>[A-Za-z0-9\-=_]{11})')
match = regex.match(self.youtube_url)
@amalgjose
amalgjose / DateDifference.py
Last active January 4, 2022 19:02
This is a very simple python code snippet for calculating the difference between two dates or timestamps. This will calculate the difference in terms of number of years, months, days, hours, minutes etc. For more details, refer https://amalgjose.com/2015/02/19/python-code-for-calculating-the-difference-between-two-time-stamps/
__author__ = 'Amal G Jose'
from datetime import datetime
from dateutil import relativedelta
##Aug 7 1989 8:10 pm
date_1 = datetime(1989, 8, 7, 20, 10)
##Dec 5 1990 5:20 am
date_2 = datetime(1990, 12, 5, 5, 20)
@burnash
burnash / django_model_graph.sh
Last active August 28, 2020 18:00 — forked from perrygeo/django_model_graph.sh
Generate Django Model Graph
apt-get install python-pygraphviz
pip install django-extensions
# add 'django_extensions' to INSTALLED_APPS in settings.py
python manage.py graph_models -a -o myapp_models.png