Skip to content

Instantly share code, notes, and snippets.

View SmugZombie's full-sized avatar

Ron Egli SmugZombie

View GitHub Profile
function getLocalStorage(name){
var now = parseInt(new Date() / 1000);
var expires = localStorage.getItem(name+"_expire");
if(!expires){ return localStorage.getItem(name); }
else if(now >= expires){ localStorage.removeItem(name+"_expire"); localStorage.removeItem(name); return ""; }
else{ return localStorage.getItem(name); }
}
function setLocalStorage(name, value, minutes){
if(minutes == null){ localStorage.setItem(name, value); localStorage.removeItem(name+"_expire"); return true} // No set expiration
@tliron
tliron / rest.py
Last active January 8, 2022 13:34
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
#!/usr/bin/env python
'''
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
Features:
* Map URI patterns using regular expressions
* Map any/all the HTTP VERBS (GET, PUT, DELETE, POST)
* All responses and payloads are converted to/from JSON for you