<!DOCTYPE html> <html> <head> <title>Geolocation</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <style> html, body, #map-canvas { height: 100%; margin: 0px; padding: 0px } </style> <!-- Include the maps javascript with sensor=true because this code is using a sensor (a GPS locator) to determine the user's location. See: https://developers.google.com/maps/documentation/javascript/tutorial#Loading_the_Maps_API --> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script> <script> // Note: This example requires that you consent to location sharing when // prompted by your browser. If you see a blank space instead of the map, this // is probably because you have denied permission for location sharing. var map; function initialize() { var mapOptions = { zoom: 6 }; map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); // Try HTML5 geolocation if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var infowindow = new google.maps.InfoWindow({ map: map, position: pos, content: 'Location found using HTML5.' }); map.setCenter(pos); }, function() { handleNoGeolocation(true); }); } else { // Browser doesn't support Geolocation handleNoGeolocation(false); } } function handleNoGeolocation(errorFlag) { if (errorFlag) { var content = 'Error: The Geolocation service failed.'; } else { var content = 'Error: Your browser doesn\'t support geolocation.'; } var options = { map: map, position: new google.maps.LatLng(60, 105), content: content }; var infowindow = new google.maps.InfoWindow(options); map.setCenter(options.position); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"></div> </body> </html>
Wednesday, March 19, 2014
Geolocation html5 & maps
Session HTML5
<!DOCTYPE html> <html lang="en"> <head> <meta charset=utf-8> <meta name="viewport" content="width=620"> <title>HTML5 Demo: Storage</title> <link rel="stylesheet" href="css/html5demos.css"> <script src="js/h5utils.js"></script></head> <body> <section id="wrapper"> <div id="carbonads-container"><div class="carbonad"><div id="azcarbon"></div><script type="text/javascript">var z = document.createElement("script"); z.type = "text/javascript"; z.async = true; z.src = "http://engine.carbonads.com/z/14060/azcarbon_2_1_0_VERT"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z, s);</script></div></div> <header> <h1>Storage</h1> </header> <style> article div { margin: 10px 0; } label { float: left; display: block; width: 125px; line-height: 32px; } </style> <article> <section> <p>Values are stored on <code>keyup</code></p> <p>Content loaded from previous sessions:</p> <ul id="previous"></ul> </section> <section> <div> <label for="session">sessionStorage:</label> <input type="text" name="session" value="" id="session" /> </div> <div> <label for="local">localStorage:</label> <input type="text" name="local" value="" id="local" /> </div> <input type="button" id="clear" value="Clear storage" /> </section> </article> <script> function getStorage(type) { var storage = window[type + 'Storage'], delta = 0, li = document.createElement('li'); if (!window[type + 'Storage']) return; if (storage.getItem('value')) { delta = ((new Date()).getTime() - (new Date()).setTime(storage.getItem('timestamp'))) / 1000; li.innerHTML = type + 'Storage: ' + storage.getItem('value') + ' (last updated: ' + delta + 's ago)'; } else { li.innerHTML = type + 'Storage is empty'; } document.querySelector('#previous').appendChild(li); } getStorage('session'); getStorage('local'); addEvent(document.querySelector('#session'), 'keyup', function () { sessionStorage.setItem('value', this.value); sessionStorage.setItem('timestamp', (new Date()).getTime()); }); addEvent(document.querySelector('#local'), 'keyup', function () { localStorage.setItem('value', this.value); localStorage.setItem('timestamp', (new Date()).getTime()); }); addEvent(document.querySelector('#clear'), 'click', function () { sessionStorage.clear(); localStorage.clear(); document.querySelector('#previous').innerHTML = ''; getStorage('local'); getStorage('session'); }); </script> <a id="html5badge" href="http://www.w3.org/html/logo/"> <img src="http://www.w3.org/html/logo/badge/html5-badge-h-connectivity-device-graphics-multimedia-performance-semantics-storage.png" width="325" height="64" alt="HTML5 Powered with Connectivity / Realtime, Device Access, Graphics, 3D & Effects, Multimedia, Performance & Integration, Semantics, and Offline & Storage" title="HTML5 Powered with Connectivity / Realtime, Device Access, Graphics, 3D & Effects, Multimedia, Performance & Integration, Semantics, and Offline & Storage"> </a> <footer><a href="/">HTML5 demos</a>/<a id="built" href="http://twitter.com/rem">@rem built this</a>/<a href="#view-source">view source</a></footer> </section> <a href="http://github.com/remy/html5demos"><img style="position: absolute; top: 0; left: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_left_darkblue_121621.png" alt="Fork me on GitHub" /></a> <script src="js/prettify.packed.js"></script> <script> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script> try { var pageTracker = _gat._getTracker("UA-1656750-18"); pageTracker._trackPageview(); } catch(err) {}</script> </body> </html>
What is a WebService?
A Web service
is the method of communications over Internet between two electronic devices.
WWW is know as Internet, but WWW is a set of the protocols.
WWW components:
HTTP is the fact protocol used over internet .
HTTP is made by Socket, the Socket is IP/Port. We have 2 kind of sockets TCP/UDP.
HTML is the view of HTTP for human.
is the method of communications over Internet between two electronic devices.
WWW is know as Internet, but WWW is a set of the protocols.
WWW components:
HTTP is the fact protocol used over internet .
HTTP is made by Socket, the Socket is IP/Port. We have 2 kind of sockets TCP/UDP.
HTML is the view of HTTP for human.
Bankier's Algorithm
The Banker's algorithm is run by the operating system whenever a process requests resources. The algorithm avoids deadlock by denying or postponing the request if it determines that accepting the request could put the system in an unsafe state (one where deadlock could occur). When a new process enters a system, it must declare the maximum number of instances of each resource type that it may ever claim; clearly, that number may not exceed the total number of resources in the system. Also, when a process gets all its requested resources it must return them in a finite amount of time.
Resources
For the Banker's algorithm to work, it needs to know three things:
How much of each resource each process could possibly request[CLAIMS]
How much of each resource each process is currently holding[ALLOCATED]
How much of each resource the system currently has available[AVAILABLE]
Resources may be allocated to a process only if it satisfies the following conditions:
request ≤ max, else set error condition as process has crossed maximum claim made by it.
request ≤ available, else process waits until resources are available.
Some of the resources that are tracked in real systems are memory, semaphores and interface access.
The Banker's Algorithm derives its name from the fact that this algorithm could be used in a banking system to ensure that the bank does not run out of resources, because the bank would never allocate its money in such a way that it can no longer satisfy the needs of all its customers. By using the Banker's algorithm, the bank ensures that when customers request money the bank never leaves a safe state. If the customer's request does not cause the bank to leave a safe state, the cash will be allocated, otherwise the customer must wait until some other customer deposits enough.
Basic data structures to be maintained to implement the Banker's Algorithm:
Let n be the number of processes in the system and m be the number of resource types. Then we need the following data structures:
Available: A vector of length m indicates the number of available resources of each type. If Available[j] = k, there are k instances of resource type Rj available.
Max: An n×m matrix defines the maximum demand of each process. If Max[i,j] = k, then Pi may request at most k instances of resource type Rj.
Allocation: An n×m matrix defines the number of resources of each type currently allocated to each process. If Allocation[i,j] = k, then process Pi is currently allocated k instances of resource type Rj.
Need: An n×m matrix indicates the remaining resource need of each process. If Need[i,j] = k, then Pi may need k more instances of resource type Rj to complete the task.
Note: Need[i,j] = Max[i,j] - Allocation[i,j].
video
Monday, March 17, 2014
ZF2 about Session & Serialize
Key concept of the Exam is Session:
Session
support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site.
A visitor accessing your web site is assigned a unique id, the so-called session id. This is either stored in a cookie on the user side or is propagated in the URL.
ZF2 & Sessions
Another concept what we should know is
Serialize
Generates a storable representation of a value.
This is useful for storing or passing PHP values around without losing their type and structure.
To make the serialized string into a PHP value again, use unserialize().
Subscribe to:
Posts (Atom)