Skip to content

Instantly share code, notes, and snippets.

Use git log --diff-filter=D --summary to get all the commits which have deleted files and the files deleted;
Use git checkout $commit~1 filename to restore the deleted file.
psql -d template1 -c 'create extension hstore;'
coverage run --source='app_name' manage.py test app_name
coverage report -m
git config core.fileMode false
youtube-dl --list-formats URL
youtube-dl --format URL
<ul>
<li ng-repeat="(key, errors) in form.$error track by $index"> <strong>{{ key }}</strong> errors
<ul>
<li ng-repeat="e in errors">{{ e.$name }} has an error: <strong>{{ key }}</strong>.</li>
</ul>
</li>
</ul>
@zealfire
zealfire / save_image.py
Last active October 31, 2016 18:03
Code snippet useful for saving image in django model when you know image's path.
def save_image(file_name, new_file_name, directory):
"""
:param file_name(string) old name of image
:param new_file_name(string) new name of image
:param directory(string) name of directory from which image has been fetched
helps to create images
"""
tags_list = ['vd-images']
applicable_languages_list = ['en']
# over here import the django model specific to images
@zealfire
zealfire / removing_file
Created November 1, 2016 08:07
use these command when you want to remove files with few exceptions
shopt -s extglob
rm !(X|Y)
$(document).ready(function() {
function jQuerySubmit(type, url, data, contentType, dataType, handler) {
$.ajax({
type: type,
url: url,
data: data,
contentType: contentType
dataType: dataType,
success: handler
});
function parseDuration(PT) {
var output = [];
var durationInSec = 0;
var matches = PT.match(/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)W)?(?:(\d*)D)?T(?:(\d*)H)?(?:(\d*)M)?(?:(\d*)S)?/i);
var parts = [
{ // years
pos: 1,
multiplier: 86400 * 365
},
{ // months