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
<script type="text/javascript"> | |
var contentArray = [ | |
... | |
]; | |
var testField = document.getElementById('test_field'); | |
testField.onkeyup = function(){ | |
if(contentArray.indexOf(testField.value) != -1) { | |
alert("It's in the array !"); | |
} else { | |
alert("It's not in the array !"); |
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.http import HttpResponse | |
import pandas as pd | |
def foo(): | |
results = pd.Dataframe() | |
response = HttpResponse(content_type='text/csv') | |
response['Content-Disposition'] = 'attachment; filename=filename.csv' | |
results.to_csv(path_or_buf=response,sep=';',float_format='%.2f',index=False,decimal=",") |
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 weasyprint import HTML | |
response = HttpResponse(content_type='application/pdf') | |
response['Content-Disposition'] = 'attachment; filename="your_pdf.pdf"' | |
html_out = str(render(request,"mock_page.html",locals())) | |
html_out = html_out.replace('Content-Type: text/html; charset=utf-8','') | |
# base_url is used to locate the CSS file | |
HTML(string=html_out,base_url = request.build_absolute_uri()).write_pdf(response) | |
return response |
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
$.extend(jQuery.fn.dataTableExt.oSort, { | |
"duration-pre": function (s) { | |
var duration; | |
s = s.toLowerCase(); | |
if(s === 'n/a'){ | |
duration = -1; | |
} else { | |
d = s.match(/(?:(\d+):)?(?:(\d+):)?(?:(\d+):)?/); | |
duration = parseInt(d[1] ? d[1] : 0) * 60 + parseInt(d[2] ? d[2] : 0) + parseInt(d[2] ? d[2] : 0) / 60; | |
} |
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
import numpy as np | |
import pandas as pd | |
import StringIO | |
def testExport(request): | |
# creating a dataframe and doing stuff about it | |
testDataframe = pd.DataFrame(np.random.randn(1,4), columns=list('ABCD')) | |
# generate output |
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
def monthrange(start_date,end_date): | |
for n in range(relativedelta(end_date,start_date).years * 12 + relativedelta(end_date,start_date).months + 1): | |
yield start_date + n*relativedelta(months=1) |