This file contains 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
localStorage.setItem("bar", foo); | |
localStorage.setItem("myObject", JSON.stringify(myObject)); | |
localStorage["foo"] = "bar" | |
localStorage.getItem("bar") | |
localStorage["bar"] | |
localStorage.removeItem("myObject"); |
This file contains 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
var str = JSON.stringify(myObject); | |
var myObj = JSON.parse(str); |
This file contains 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
f = open('myfile','w') | |
f.write('hi there\n') # python will convert \n to os.linesep | |
f.close() |
This file contains 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
import urllib | |
link = "http://www.somesite.com/details.pl?urn=2344" | |
f = urllib.urlopen(link) | |
myfile = f.read() | |
print myfile |
This file contains 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
payload = {"auth" : {"passwordCredentials" : {"username": username, "password": password}}} | |
headers = {'content-type': 'application/json'} | |
r = requests.post(url, data=json.dumps(payload), headers = headers) | |
result = r.json() | |
print result["access"]["token"] |
This file contains 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
// requires snap-svg.js | |
function animateOverPath(el, path, duration, callback) { | |
len = path.getTotalLength(); | |
Snap.animate(0, len, function (l) { | |
var dot = path.getPointAtLength(l); | |
x = dot.x - el.getBBox().width/2; | |
y = dot.y - el.getBBox().height/2; | |
el.attr({ | |
transform: "t" + [x,y] + "r" + (dot.alpha - 180) | |
}); |
This file contains 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
// runner | |
function Runner() { | |
this.descriptionDefer = $.Deferred(); | |
this.descriptionPromise = this.descriptionDefer.promise(); | |
} | |
Runner.prototype.stop = function() { | |
this.descriptionDefer.resolve(this.descriptionDefer); | |
} |
This file contains 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($) { | |
$.fn.blink = function(duration) { | |
// check specifically for display => works with svg elements | |
var hidden = $(this).css("display") == "none" || $(this).is(":hidden"); | |
if (hidden) { | |
var self = this.show(); | |
setTimeout(function() { | |
self.hide(); | |
}, duration); | |
} |
This file contains 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
#Installing old gnome | |
sudo apt-get install gnome-session-fallback | |
#(might need a sudo-apt get update first) | |
#Login to commandline | |
#To Commandline: CTRL+ALT+F1 | |
#Back to Login: CTRL+ALT+F7 | |
#Release info |
This file contains 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
#!/bin/bash | |
source ${openrc:-~/openrc} | |
ext_net=${ext_net:-external} | |
no_gw=${no_gw:-nogw} | |
hostname=${1:-test} | |
key_name=${key_name:-public} | |
flavor=${flavor:-2} | |
image=${image:-precise-x86_64} | |
user_data=${user_data:-~/user.data} | |
net_id=`neutron net-list | grep ${ext_net} | awk -F' ' '{print $2}'` |
OlderNewer