Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Petar Bojinov pbojinov

🏠
Working from home
View GitHub Profile
@pbojinov
pbojinov / base64.py
Created Mar 26, 2014
base64 encode/decode
View base64.py
import base64
encoded = base64.b64encode('b604de2f-bfe4-4449-9f31-3d6695918327')
assert (encoded == 'YjYwNGRlMmYtYmZlNC00NDQ5LTlmMzEtM2Q2Njk1OTE4MzI3')
decoded = base64.b64decode(encoded)
assert (decoded == 'b604de2f-bfe4-4449-9f31-3d6695918327')
@pbojinov
pbojinov / datetime.py
Created Mar 26, 2014
using python datetime for current time and time next year
View datetime.py
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
@pbojinov
pbojinov / string_formatting.py
Created Mar 27, 2014
string formatting in python
View string_formatting.py
# The sophosticated way
formatted_string = "My {0} has {1} whiskers and {2} paws".format('cat', 30, 4)
print formatted_string
@pbojinov
pbojinov / ga.javascript.error.js
Created Apr 15, 2014
Track JavaScript Errors with Google Analytics
View ga.javascript.error.js
//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
View dynamic-font-size.css
html {
font-size: 62.5%;
}
body {
font-size: 1em;
}
@media (max-width: 300px) {
html {
View framebusters.html
<style> html{display:none;} </style>
<script>
if(self == top) {
document.documentElement.style.display = 'block';
}
else {
top.location = self.location;
}
</script>
@pbojinov
pbojinov / array.deferred.js
Last active Aug 29, 2015
array of deferred
View array.deferred.js
var doStuff = doAsyncThings();
$.when.apply(null, doStuff).done(function() {
console.log('done with async stuff');
});
function doAsyncThings() {
var deferreds = [];
deferreds.push(function() {
@pbojinov
pbojinov / index.html
Last active Aug 29, 2015
double inner box shadow
View index.html
<!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*/
@pbojinov
pbojinov / enableHotCorners.scpt
Created May 28, 2014
applescript to enable hot corners
View enableHotCorners.scpt
-- 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.
@pbojinov
pbojinov / disableHotCorners.scpt
Created May 28, 2014
applescript to disable hot corners
View disableHotCorners.scpt
-- 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.