Skip to content

Instantly share code, notes, and snippets.

View vitkon's full-sized avatar
🎨
Building accessible UIs

Vitaly Kondratiev vitkon

🎨
Building accessible UIs
View GitHub Profile
@vitkon
vitkon / JS Inhertence
Last active August 29, 2015 13:56
Simple JS Prototype chain
var Person = function (name) {
this.name = name;
}
Person.prototype.test = function () {
return 'This is person test';
}
Person.prototype.describe = function () {
return 'This is ' + this.name;
@vitkon
vitkon / gist:0e3a5d4842475868b8e2
Created August 26, 2014 05:27
JavaScriptCore symlink for OSX
sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /bin/jsc
@vitkon
vitkon / gist:0c2efb70103332715e44
Created November 17, 2014 16:27
Get url parameter by name
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
<h3>Choose a building</h3>
Current building: {{currentBuilding.name}}
<select>
{{#each buildings}}
<option value="{{_id}}" selected={{equals _id currentBuilding._id}}>{{name}}</option>
{{/each}}
</select>
@vitkon
vitkon / gist:5672858
Created May 29, 2013 19:01
CSS: Display URLs In A Printed Webpage
@media print {
a:after {
content: " [" attr(href) "] ";
}
}
@vitkon
vitkon / gist:5672920
Created May 29, 2013 19:10
CSS: Clearfix
.clearfix:before, .container:after { content: ""; display: table; }
.clearfix:after { clear: both; }
/* IE 6/7 */
.clearfix { zoom: 1; }
@vitkon
vitkon / gist:5672988
Created May 29, 2013 19:17
CSS: General media queries
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}
@vitkon
vitkon / gist:5673058
Created May 29, 2013 19:26
JS: Test email validity
function checkMail (email) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(email)) {
return true;
}
return false;
}
@vitkon
vitkon / gist:5673129
Last active December 17, 2015 21:10
JS: Safe console.log (cross-browser)
// make it safe to use console.log always
(function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;!!(d=c.pop());){a[d]=a[d]||b;}})
(function(){try{console.log();return window.console;}catch(a){return (window.console={});}}());
@vitkon
vitkon / gist:5673222
Last active December 17, 2015 21:10
JS: Resize iFrame to its content
$("#modalIFrame").bind('load',
function () {
var newheight,
newwidth;
newheight = this.contentWindow.document.body.scrollHeight;
newwidth = this.contentWindow.document.body.scrollWidth;
$(this).height(newheight);
$(this).width(newwidth);