Skip to content

Instantly share code, notes, and snippets.

View beshur's full-sized avatar

Alex Buznik beshur

View GitHub Profile
@beshur
beshur / gist:3784280
Created September 25, 2012 20:35
jQuery Opera 50% border-radius for images
<div class="content"><img src="http://placehold.it/250x250" /></div>
<style type="text/css">
img {
border-radius: 50%;
}
.o-border-radius {
display: block;
border-radius: 50%;
overflow: hidden;
@beshur
beshur / wc10.html
Created September 27, 2012 23:21 — forked from nithinbekal/wc10.html
JavaScript Countdown timer
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>World Cup 2010 Countdown Timer</title>
</head>
<body>
<div id="worldcup_countdown_time"> </div>
<script src="wc10.js" type="text/javascript" charset="utf-8"></script>
@beshur
beshur / gist:3800457
Created September 28, 2012 15:15
jQuery scroll to the bottom of the page
$('html, body').animate({scrollTop: $(document).height()}, 'slow');
@beshur
beshur / gist:3834282
Created October 4, 2012 15:14
jQuery simple form validation
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pattern.test(emailAddress);
@beshur
beshur / gist:3898084
Created October 16, 2012 08:42
jQuery registration form validation
$("form.popup [data-validate]").blur(function (e) {
var dv = $(this).attr("data-validate");
if ( $(this).hasClass("error") ) var err_set = true;
var error = 0;
var c = $(this).val();
if ( dv == "email" ) {
var reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
@beshur
beshur / gist:4116813
Created November 20, 2012 08:53 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts MAC

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@beshur
beshur / gist:4124512
Created November 21, 2012 11:50
Sublime Text 2 - Useful Shortcuts Windows

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@beshur
beshur / style.css
Created November 28, 2012 13:46
CSS dummy
/* Cooper Burgers CSS */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
border: 0;
@beshur
beshur / scripts.js
Created November 30, 2012 10:31
jQuery dummy
/* Bankoscopo JS */
var page_var = {
w_w: $(window).width(),
w_h: $(window).height(),
s_t: $("html, body").scrollTop()
}
$(function() {
@beshur
beshur / gist:5063527
Created March 1, 2013 09:34
PHP generate two different random numbers simple
<?
$present_in = rand(0,4);
$present_in2 = $present_in;
while ($present_in2 == $present_in) {
$present_in2 = rand(0,4);
}
?>