This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import re | |
import subprocess | |
import sys | |
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)') | |
CHECKS = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git filter-branch --index-filter 'git rm --cached --ignore-unmatch <file_path_or_pattern>' --tag-name-filter cat -- --all | |
git push origin --force --all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.classWithShadow{ | |
-moz-box-shadow: 1px 1px 2px grey, 0 0 25px lightgrey; | |
-webkit-box-shadow: 1px 1px 2px grey, 0 0 25px lightgrey; | |
box-shadow: 1px 1px 2px grey, 0 0 25px lightgrey; | |
} | |
</style> | |
<!doctype HTML> | |
<head></head> | |
<div class="shadowclass"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BootstrapMixinForm(forms.ModelForm): | |
""" | |
Sample Django Form To add Bootstrap's Form Control class to every field. | |
""" | |
def __init__(self, *args, **kwargs): | |
super(BootstrapMixinForm, self).__init__(*args, **kwargs) | |
for myField in self.fields: | |
self.fields[myField].widget.attrs['class'] = 'form-control' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reset_element(element_id, element_type){ | |
var child = document.getElementById(div_id); | |
var parent = child.parentElement; | |
var new_child = document.createElement(element_type); | |
parent.removeChild(child); | |
new_child.setAttribute('id', div_id); | |
parent.appendChild(new_child); | |
} | |
// <span id="my_canvas_id"></span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class APIDetailView(APIView): | |
authentication_classes = (CsrfExemptSessionAuthentication, BasicAuthentication) | |
http_method_names = ('get', ) | |
serializer_class = ModelSerializer | |
def get(self, request, pk, **kwargs): | |
obj = Chapter.objects.get(id=pk) | |
serializer = ModelSerializer(obj, context={"request": request}) | |
return Response(serializer.data, status=status.HTTP_200_OK) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.files import File | |
from django.core.files.uploadedfile import InMemoryUploadedFile | |
from django.core.files.temp import NamedTemporaryFile | |
from newspaper import Article | |
import requests | |
from myapp.models import Blog, Category, Tags | |
__author__ = 'jerinisready' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.response import Response | |
import rest_framework.views | |
class APIView(rest_framework.views.APIView): | |
""" A Quick Login Required Mixin For Django Rest Framework """ | |
def dispatch(self, request, *args, **kwargs): | |
if not request.user.is_authenticated(): | |
return Response({'error': 'Please Authenticate to continue'}, status=405) | |
return super(self.__class__, self).dispatch(request, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = """https://stackoverflow.com/a/17388505/9662240""" | |
from difflib import SequenceMatcher | |
def similar(a, b): | |
return SequenceMatcher(None, a, b).ratio() | |
""" | |
>>> similar("Apple","Appel") | |
0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('.height-outer').each(function(){ | |
var highestBox = 0; | |
$('.equilheight', this).each(function(){ | |
if($(this).height() > highestBox) { | |
highestBox = $(this).height(); | |
} | |
}); | |
$('.equilheight',this).height(highestBox); | |
}); |