var polygon = L.polygon([
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.047]
]).addTo(mymap);
JSON.stringify(polygon.toGeoJSON().geometry.coordinates[0])
"[[-0.08,51.509],[-0.06,51.503],[-0.047,51.51],[-0.08,51.509]]"
var a = [];
mymap.eachLayer(l=>'toGeoJSON' in l && a.push(l.toGeoJSON()));
var result = {"type":"FeatureCollection","features":a};
console.log(JSON.stringify(result,"\n",4))
<script>
var a=new Audio,
p= function(s){a.pause();a.currentTime = 0;a.volume =0.9;a.src=s;a.play();return true;};
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function(e) {
switch(e.orientation){
case "portrait": return p('sneeze.mp3');
case "landscape": return p('blow_nose.mp3');
}}, false);
</script><style>div{text-align:center;margin:20px;}button{padding:20px}</style>
<div><button onclick="p('sneeze.mp3')">SNEEZE</button></div>
<div><button onclick="p('blow_nose.mp3')">BLOW NOSE</button></div>
<div><button onclick="p('take.mp3')">TAKE MEDI</button></div>
import json
import requests
clientCrt = "cc.crt"
clientKey = "ck.key"
url = "https://example.com/api"
payload = { "someId": "myID" }
certServer = 'cs.crt'
headers = {'content-type': 'application/json'}
r = requests.post(url, data=json.dumps(payload), verify=certServer, headers=headers, cert=(clientCrt, clientKey))
print(r.status_code)
print(r.json())
$.ajax({
...
success: function(data) {
var file=document.createElement('a');
file.href=window.URL.createObjectURL(new Blob([data],{type: "application/pdf"}));
file.download="Report.pdf";
file.click();
}
});
$.ajax({
...
success: function(data) {
chrome.downloads.download({
url : URL.createObjectURL(new Blob([data],{type: "application/pdf"})),
filename : "Report.pdf",
conflictAction : 'uniquify'
});
}
});
Content-Encoding: gzip
import gzip
import io
def gzip_str(string_):
out = io.BytesIO()
with gzip.GzipFile(fileobj=out, mode='w') as fo:
fo.write(string_.encode())
bytes_obj = out.getvalue()
return bytes_obj
def gunzip_bytes_obj(bytes_obj):
in_ = io.BytesIO()
in_.write(bytes_obj)
in_.seek(0)
with gzip.GzipFile(fileobj=in_, mode='rb') as fo:
gunzipped_bytes_obj = fo.read()
return gunzipped_bytes_obj.decode()
string_ = 'hello there!'
gzipped_bytes = gzip_str(string_)
original_string = gunzip_bytes_obj(gzipped_bytes)
assert string_ == original_string