Skip to content

Instantly share code, notes, and snippets.

@irae
irae / _Stay_standalone.md
Last active January 29, 2024 12:38 — forked from kylebarrow/example.html
Stay Standalone: Prevent links in standalone web apps opening Mobile Safari

#Stay Standalone

A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.

#!/usr/bin/python
# coding: utf-8
import urllib
import urllib2
from multiprocessing import Pool
import Queue, threading
reg_nos = [16738, 17288, 18162, 18776, 18868, 19116, 19223, 19505];
pdf_url = 'http://www.mapa.es/agricultura/pags/fitos/registro/sustancias/pdf/%s.pdf'
@vicalejuri
vicalejuri / django-crossdomainxhr-middleware.py
Created June 5, 2010 17:47
Middlware to allow's your django server to respond appropriately to cross domain XHR (postMessage html5 API).
import re
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
from django import http
try:
import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
@wil
wil / gist:347596
Created March 29, 2010 08:25
Django Setting Expires Header in XHR Response
import time
from django.utils.http import http_date
AJAX_NEGATIVE_CHECK_EXPIRES = 60 # object is still available
AJAX_POSITIVE_CHECK_EXPIRES = 60*10 # if object is not available (or taken)
def check_ajax(request):
# do stuff here
timeout = AJAX_NEGATIVE_CHECK_EXPIRES if avail else AJAX_POSITIVE_CHECK_EXPIRES