Skip to content

Instantly share code, notes, and snippets.

@tborychowski
tborychowski / _.md
Last active August 29, 2015 14:07
radial
@tborychowski
tborychowski / gmail.py
Last active August 29, 2015 14:05 — forked from vadviktor/gmail.py
Gmail imap checker
#!/usr/bin/env python
def gmail_checker(username,password):
import imaplib,re
i=imaplib.IMAP4_SSL('imap.gmail.com')
try:
i.login(username,password)
x,y=i.status('INBOX','(MESSAGES UNSEEN)')
messages=int(re.search('MESSAGES\s+(\d+)',y[0]).group(1))
unseen=int(re.search('UNSEEN\s+(\d+)',y[0]).group(1))
return (messages,unseen)
@tborychowski
tborychowski / user-location.js
Created August 22, 2014 12:56
JS :: user location
$.ajax({ url: '//www.google.com/jsapi', dataType: 'script' }).done(function () {
var addr = google.loader.ClientLocation.address;
console.log(addr);
});
$.getJSON('//freegeoip.net/json/', function(location) {
console.log(location);
});
@tborychowski
tborychowski / weird.js
Last active August 29, 2015 14:05
JS :: weirdness
fail
f (![]+[])[+[]]
a (![]+[])[+!+[]]
i ([![]]+[][[]])[+!+[]+[+[]]]
l (![]+[])[!+[]+!+[]]
t (!![]+[])[+[]]
@tborychowski
tborychowski / get-url-vars.js
Created August 22, 2014 12:53
JS :: get url vars
_getUrlVars = function () {
var vars = {},
parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
vars[key] = value;
});
return vars;
}
@tborychowski
tborychowski / fuzzy.js
Created August 22, 2014 12:51
JS :: fuzzy search
String.prototype.fuzzy = function (s) {
var hay = this.toLowerCase(), i = 0, n = -1, l;
s = s.toLowerCase();
for (; l = s[i++] ;) if (!~(n = hay.indexOf(l, n + 1))) return false;
return true;
};
('a haystack with a needle').fuzzy('hay sucks'); // false
('a haystack with a needle').fuzzy('sack hand'); // true
@tborychowski
tborychowski / firebug.js
Created August 22, 2014 12:49
Firebug Colours
console.log('%cERROR: %c siema %c tom',
'font: bold 12px arial; color:red; line-height:2.6em;',
'font: 12px arial; color:green;',
'font: 12px arial; color:blue;'
);
@tborychowski
tborychowski / mydate.js
Created August 22, 2014 12:06
JS :: date functions
/* DATE FUNCTIONS */
Date.months = [
{ shortName: 'jan', days: 31, name: 'January' },
{ shortName: 'feb', days: 28, name: 'February' },
{ shortName: 'mar', days: 31, name: 'March' },
{ shortName: 'apr', days: 30, name: 'April' },
{ shortName: 'may', days: 31, name: 'May' },
{ shortName: 'jun', days: 30, name: 'June' },
{ shortName: 'jul', days: 31, name: 'July' },
{ shortName: 'aug', days: 31, name: 'August' },
@tborychowski
tborychowski / jquery-alt-animate.js
Created August 22, 2014 11:54
JS :: jquery alt animate
$({ a:0 }).animate({ a:.3 },{
duration: 1000,
step: function(){
// do something
},
complete: function(){
}
});
@tborychowski
tborychowski / css-transition-end.js
Last active August 29, 2015 13:56
JS :: detect css transition end
/* From Modernizr */
function whichTransitionEvent() {
var el = document.createElement('fakeelement'), t,
transitions = {
'transition': 'transitionend',
'OTransition': 'oTransitionEnd',
'MozTransition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd',
'MsTransition': 'msTransitionEnd'
};