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
#!/usr/bin/python | |
import subprocess | |
import time | |
import urllib | |
import usblamp | |
import signal | |
import sys |
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
$memcache = new Memcache; | |
$memcache->connect("localhost",11211); | |
echo "Server's version: " . $memcache->getVersion() . "<br />\n"; | |
$data = 'This is working'; | |
$memcache->set("key",$data,false,10); | |
echo "cache expires in 10 seconds<br />\n"; | |
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
$cachetime = 10; // number of seconds to cache for | |
$data = array(); | |
$data['cachereset'] = 0; | |
// cache calls | |
$startTime = microtime(true); | |
$this->load->driver('cache'); | |
$cache = $this->cache->memcached->get('alluserscount'); | |
if (!$cache){ | |
$data['cachereset'] = 1; |
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
$config= array( | |
'default' => array( | |
'host' => '127.0.0.1', | |
'port' => 11211, | |
'weight' => 80 | |
), | |
'server_1' => array( | |
'host' => '127.0.0.2', | |
'port' => 11211, | |
'weight' => 50 |
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
<!DOCTYPE html> | |
<html manifest="wsdemo.manifest"> | |
<head> | |
<meta name="viewport" content="width=device-width"> |
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
window.addEventListener("DOMContentLoaded", loadSavedData, false);// load locally saved data when the page opens | |
// get the locally saved data | |
function loadSavedData(){ | |
savedData = localStorage.getItem("data"); // get data from local storage | |
if (savedData && savedData != null) { // if not empty | |
savedData = JSON.parse(savedData); // get data from returned json string | |
savedData = savedData['dataToSave']; // set savedData from dataToSave item | |
showListItems();// Generate the list items and display |
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
// save the new list locally | |
function saveLocally(dataToSave){ | |
var cleanData = JSON.stringify({dataToSave: dataToSave}); // generate clean data | |
localStorage.setItem("data", cleanData); // save new data locally | |
showListItems(); // refresh the list display | |
showLocalData(); // update localdata display | |
} |
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
// display if they are online or not | |
if (!navigator.onLine){ | |
$('#status').html('Offline'); | |
} else { | |
$('#status').html('Online'); | |
} |
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
function runStorageTest(){ // fill up all data in local storage to see how much we can squeeze in | |
localStorage.clear(); | |
var i = 0; | |
var testPacket = new Array( 1025 ).join( "a" ); // create 1024 characters so 1KB | |
while (i<maxMBToTest){ // MB level | |
$('#currentDisplay').html(i+'Mb'); | |
var t = 0; | |
while (t<1025){ // KB level | |
try { | |
localStorage.setItem(i+"|"+t, testPacket); |
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
function sizeofAllStorage(){ // provide the size in bytes of the data currently stored | |
var size = 0; | |
for (i=0; i<=localStorage.length-1; i++) | |
{ | |
key = localStorage.key(i); | |
size += lengthInUtf8Bytes(localStorage.getItem(key)); | |
} | |
return size; | |
} |