This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<kml xmlns="http://www.opengis.net/kml/2.2"> | |
<Document> | |
<Style id="s1"> | |
<LineStyle> | |
<color>7f0000ff</color> | |
<width>4</width> | |
</LineStyle> | |
<PolyStyle> | |
<color>7f0000ff</color> |
This file contains hidden or 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
response = HttpResponse(content_type='text/csv') | |
response['Content-Disposition'] = 'attachment; filename="data.csv"' | |
writer = csv.writer(response) | |
result = [{"user": 'jai', "email": "[email protected]"}, {"user": 'jai', "email": "[email protected]"}.............] | |
if result: | |
header= result[0].keys() | |
writer.writerow(header) | |
for row in result: | |
data = [] | |
for key in header: |
This file contains hidden or 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
// js where you add header for the table dynamically | |
field = "user_type" | |
field_split = field.split("_") | |
field_text = field_split.join(" ") | |
console.log(field_text) // user type | |
var th = $('<th>', { | |
text : field_text, | |
class: "text-capitalize", | |
}) |
This file contains hidden or 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 JsonResponseMixin(object): | |
""" | |
Return json | |
""" | |
def render_to_response(self, context): | |
queryset = self.model.objects.all() | |
data = serializers.serialize('json', queryset) | |
return HttpResponse(data, content_type='application/json') | |
JSON parsing using getJSON |
This file contains hidden or 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
def myview(request) | |
customer = request.session['Customer'] | |
template = preppy.getModule(settings.REPORTS_DIR + '/report_templates/prepfiles/hello.prep') | |
rmlText = template.get(customer) | |
response = HttpResponse(mimetype='application/pdf') | |
response['Content-Disposition'] = 'attachment; filename=hello.pdf' | |
pdf = rml2pdf.parseString(rmlText) | |
response.write(pdf.read()) | |
return response |
This file contains hidden or 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 sklearn.cluster import KMeans | |
from sklearn import metrics | |
import cv2 | |
# By Adrian Rosebrock | |
import numpy as np | |
import cv2 | |
# Load the image | |
image = cv2.imread("red.png") |
This file contains hidden or 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
import requests | |
from bs4 import BeautifulSoup | |
def get_image_url(purchase_url): | |
""" | |
Method to get HTML content from Lowes store and return product image | |
@params purchase_url : product url | |
@outpout : img url | |
""" | |
html = requests.get(purchase_url).text |
This file contains hidden or 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
@task | |
def hello(): | |
print "hello world" | |
task = hello.delay() | |
task_id = task.id | |
from celery.result import AsyncResult | |
state = AsyncResult(task_id).state | |
print state # you can get the task status |
This file contains hidden or 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
import json | |
from django.http import HttpResponse | |
def SearchView(request): | |
project = request.GET.get('project', '') | |
role = request.GET.get('role', '') | |
#query = MODEL.objects.filter() | |
query = None | |
if query: | |
result = [{'is_already_approved':True}] | |
else: |
OlderNewer