Skip to content

Instantly share code, notes, and snippets.

View korof's full-sized avatar

Krzysztof Kornacki korof

  • Katowice, Poland
View GitHub Profile
@korof
korof / gist:8675534
Created January 28, 2014 20:21
jQuery: Test password strength
$('#pass').keyup(function(e) {
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");
if (false == enoughRegex.test($(this).val())) {
$('#passstrength').html('More Characters');
} else if (strongRegex.test($(this).val())) {
$('#passstrength').className = 'ok';
$('#passstrength').html('Strong!');
} else if (mediumRegex.test($(this).val())) {
@korof
korof / gist:8675503
Created January 28, 2014 20:20
jQuery: Preload images
$.preloadImages = function() {
for(var i = 0; i<arguments.length; i++) {
$("<img />").attr("src", arguments[i]);
}
}
$(document).ready(function() {
$.preloadImages("hoverimage1.jpg","hoverimage2.jpg");
});
@korof
korof / gist:8675468
Created January 28, 2014 20:18
jQuery: Partial page refresh
setInterval(function() {
$("#refresh").load(location.href+" #refresh>*","");
}, 10000); // milliseconds to wait
@korof
korof / gist:8595695
Created January 24, 2014 11:26
CSS: Vertical align anything
.element {
position: relative;
top: 50%;
transform: translateY(-50%);
}
It works straight out of the box, even in IE9!
@mixin vertical-align {
position: relative;
@korof
korof / gist:8530582
Created January 20, 2014 22:30
CSS: Stopka zawsze na samym dole strony
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
@korof
korof / Package Control.sublime-settings
Last active January 1, 2016 15:09
Sublime Text: Package Control.sublime-settings
{
"installed_packages":
[
"BracketHighlighter",
"CSScomb",
"DocBlockr",
"Emmet",
"Gist",
"HTML Boilerplate",
"jQuery Snippets pack",
@korof
korof / gist:8161076
Created December 28, 2013 16:09
HTML: Starting template
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">