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 base64 | |
encoded = base64.b64encode('b604de2f-bfe4-4449-9f31-3d6695918327') | |
assert (encoded == 'YjYwNGRlMmYtYmZlNC00NDQ5LTlmMzEtM2Q2Njk1OTE4MzI3') | |
decoded = base64.b64decode(encoded) | |
assert (decoded == 'b604de2f-bfe4-4449-9f31-3d6695918327') |
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
from datetime import timedelta, datetime | |
# current time | |
now = datetime.now() | |
print now | |
# a year from now | |
next_year = (datetime.today()+ timedelta(days=365)) | |
print next_year |
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
# The sophosticated way | |
formatted_string = "My {0} has {1} whiskers and {2} paws".format('cat', 30, 4) | |
print formatted_string |
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
//http://davidwalsh.name/track-errors-google-analytics?utm_source=javascriptweekly&utm_medium=email | |
// Track basic JavaScript errors | |
window.addEventListener('error', function(e) { | |
_gaq.push([ | |
'_trackEvent', | |
'JavaScript Error', | |
e.message, | |
e.filename + ': ' + e.lineno, | |
true |
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
html { | |
font-size: 62.5%; | |
} | |
body { | |
font-size: 1em; | |
} | |
@media (max-width: 300px) { | |
html { |
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
<style> html{display:none;} </style> | |
<script> | |
if(self == top) { | |
document.documentElement.style.display = 'block'; | |
} | |
else { | |
top.location = self.location; | |
} | |
</script> |
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 doStuff = doAsyncThings(); | |
$.when.apply(null, doStuff).done(function() { | |
console.log('done with async stuff'); | |
}); | |
function doAsyncThings() { | |
var deferreds = []; | |
deferreds.push(function() { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>box shadow</title> | |
<style> | |
.item { | |
background: orange; | |
border: solid 1px blue; | |
box-shadow: inset 0 0 0 1px red, inset 0 0 0 2px green; /* nesting inset shadow*/ |
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
-- By Richard Kulesus, 2009. Released without license! | |
-- Use this for whatever! | |
-- I seriously despise code authors who copyright tiny bits of obvious code | |
-- like it's some great treasure. This is small and simple, and if it saves | |
-- the next guy some time and trouble coding applescript I'll feel good! | |
-- | |
-- Quickly change all the hot-corners to do what you want. | |
-- Particularly useful for presentations and full-screen games. | |
-- Customize the activity of each hot-corner with "all windows/application windows/dashboard/disable screen saver/none/notification center/show desktop/sleep display/start screen saver" | |
-- The MODIFIERS are the keys which can be used to supplement hot-corner activation. |
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
-- By Richard Kulesus, 2009. Released without license! | |
-- Use this for whatever! | |
-- I seriously despise code authors who copyright tiny bits of obvious code | |
-- like it's some great treasure. This is small and simple, and if it saves | |
-- the next guy some time and trouble coding applescript I'll feel good! | |
-- | |
-- Quickly change all the hot-corners to do what you want. | |
-- Particularly useful for presentations and full-screen games. | |
-- Customize the activity of each hot-corner with "all windows/application windows/dashboard/disable screen saver/none/show desktop/show spaces/sleep display/start screen saver" | |
-- The MODIFIERS are the keys which can be used to supplement hot-corner activation. |
OlderNewer