Skip to content

Instantly share code, notes, and snippets.

@baniol
baniol / send_url.js
Last active December 18, 2015 22:49
sends page url via ajax, location.href
// automatyczne wysłanie urla po załadowaniu strony
var urlToSend = window.location.href.replace(window.location.host, '').replace(window.location.protocol, "").replace("///", "");
$.post("/ajax.php", {
url: urlToSend,
akcja: 'zapisz_url_test'
});
@baniol
baniol / jquery.plugin.boilerplate.js
Last active June 13, 2017 14:35
jQuery lightweight plugin boilerplate.
/*!
* jQuery lightweight plugin boilerplate
* Original author: @ajpiano
* Further changes, comments: @addyosmani
* Licensed under the MIT license
*/
// http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
// the semi-colon before the function invocation is a safety
@baniol
baniol / js_swipe.js
Last active December 19, 2015 11:59
js touch swipe.
// From: http://stackoverflow.com/questions/8098107/horizontal-swipe-slider-with-jquery-and-touch-devices-support
touch_object.prototype.handle_touchstart = function(e){
if (e.targetTouches.length != 1){
return false;
}
this.obj.style.zIndex = 100;
e.preventDefault();
this.startX = e.targetTouches[0].pageX - this.geometry.x;
this.startY = e.targetTouches[0].pageY - this.geometry.y;
/* adjust for left /top */
// Media Queries in Sass 3.2
//
// These mixins make media queries a breeze with Sass.
// The media queries from mobile up until desktop all
// trigger at different points along the way
//
// And important point to remember is that and width
// over the portrait width is considered to be part of the
// landscape width. This allows us to capture widths of devices
// that might not fit the dimensions exactly. This means the break
@baniol
baniol / _media-queries.scss
Created July 9, 2013 22:18 — forked from stammy/_media-queries.scss
css media queries sass
// $mq-mobile-portrait : 320px !default;
// $mq-mobile-landscape : 480px !default;
// $mq-tablet-portrait : 640px !default; -- changed because i want my blog content is around this wide, not 768. you should let content & design determine your breakpoints
// $mq-tablet-landscape : 1024px !default;
// $mq-desktop : 1382px !default;
$mq-mobile-portrait : 20em !default;
$mq-mobile-landscape : 30em !default;
$mq-tablet-portrait : 40em !default;
$mq-tablet-landscape : 64em !default;
@baniol
baniol / querystring.js
Created October 19, 2013 17:44
jquery get uri param
(function($) {
$.QueryString = (function(a) {
if (a == "")
return {};
var b = {};
for (var i = 0; i < a.length; ++i) {
var p = a[i].split('=');
if (p.length != 2)
continue;
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
@baniol
baniol / bash_profile
Created December 9, 2013 14:34
bash_profile, terminal, linux
PS1="☁ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f ~/.bash_colors ]; then
. ~/.bash_colors
fi
PATH=/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/:$PATH
@baniol
baniol / jsonp.html
Created December 9, 2013 15:31
jsonp implementation
<!DOCTYPE html>
<html lang="en">
<head>
<title>AvLabz - CORS : The Secrets Behind JSONP </title>
<meta charset="UTF-8" />
</head>
<body>
<input type="text" id="username" placeholder="Enter Your Name"/>
<button type="submit" onclick="sendRequest()"> Send Request to Server </button>
<script>
@baniol
baniol / server-sent.html
Created December 9, 2013 15:34
html5 server sent events, push
<!DOCTYPE html>
<html>
<head>
<title>Template html</title>
</head>
<body>
<!-- FROM: http://www.w3schools.com/html/html5_serversentevents.asp -->
<div id="result"></div>
<script type="text/javascript" src="script.js"></script>
</body>
@baniol
baniol / view_get_all
Created December 12, 2013 06:03
sublime text 3, get all content of a file
view.substr(sublime.Region(0, view.size()))