Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / _.md
Last active August 29, 2015 14:07
radial
@tborychowski
tborychowski / radial.js
Created October 6, 2014 20:54
d3 multi-series donut / arc-ular graph
var s = 1, e = s + 4;
var data = d3.range(s, e);
var col = d3.scale.category10();
var scal = d3.scale.linear()
.domain([data[0], data[data.length-1]])
.range([0, 1]);
var g = d3.select('svg');
var groups = g.selectAll('g').data(data).enter().append('g');
@tborychowski
tborychowski / js-inheritance.js
Created October 14, 2014 09:19
JS inheritance
if (!Function.prototype.bind) {
Function.prototype.bind = function (context) {
if (typeof this !== 'function') throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
var args = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fn = function () {},
fBound = function () {
return fToBind.apply(this instanceof fn && context ? this : context,
args.concat(Array.prototype.slice.call(arguments)));
};
[mergetool]
prompt = false
keepBackup = false
keepTemporaries = false
[merge]
tool = winmerge
[mergetool "winmerge"]
name = WinMerge
<form class="form">
<input type="text" placeholder="enter text" name="name" value="">
<input type="checkbox" name="check">
<select name="select"><option value="select1">one</option><option value="select2">two</option></select>
<input name="radio" type="radio" value="radio1">
<input name="radio" type="radio" value="radio2">
</form>
<button class="start">Observe</button>
<button class="stop">Stop observing</button>
@tborychowski
tborychowski / yt-downloader.user.js
Last active October 7, 2016 12:34
JS :: yt downloader monkey script
// ==UserScript==
// @name Download YouTube Videos as MP4
// @description Adds a button that lets you download YouTube videos.
// @homepageURL https://github.com/gantt/downloadyoutube
// @author Gantt
// @version 1.8.8
// @date 2016-09-02
// @namespace http://googlesystem.blogspot.com
// @include http://www.youtube.com/*
// @include https://www.youtube.com/*
@tborychowski
tborychowski / form-validation.html
Last active November 21, 2017 10:10
form-validation.html
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="css/style.css">
<style>
html { height: 100%; }
body {
font-family: sans-serif;
font-weight: 300;
@tborychowski
tborychowski / animated-dialog.html
Created July 13, 2018 07:33
html dialog with animation
<!DOCTYPE html>
<head>
<meta charset=UTF-8>
<title>Dialog demo</title>
<style>
.dialog {
border: none;
border-radius: 3px;
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
}