Skip to content

Instantly share code, notes, and snippets.

View qmmr's full-sized avatar

Marcin Kumorek qmmr

View GitHub Profile
@qmmr
qmmr / httpd-vhost.conf
Created January 31, 2012 17:27
vhost for xampp
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
@qmmr
qmmr / slider.js
Created February 21, 2012 21:32
Basic image slider, procedural style
// basic slider, the procedural method
(function($) {
var $sliderNav = $('#slider-nav'),
$sliderUL = $('div.slider').css('overflow', 'hidden').find('ul'),
imgs = $sliderUL.find('img'),
imgWidth = imgs[0].width,
numOfImgs = imgs.length,
currentImage = 1,
totalImgsWidth = imgWidth * numOfImgs;
@qmmr
qmmr / animLoopX.js
Created April 3, 2012 08:01 — forked from louisremi/animLoopX.js
Animation loop with requestAnimationFrame
// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
@qmmr
qmmr / index.html
Created May 7, 2012 17:09
HTML5 Boilerplate v4.0
<!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,chrome=1">
<title></title>
<meta name="description" content="">
@qmmr
qmmr / extend_string.js
Created May 15, 2012 10:17
JavaScript: extending native String with capitalize
// adding capitalize method to String object
if (!String.prototype.capitalize) {
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
}
@qmmr
qmmr / _gvimrc
Created August 2, 2012 21:25
VIM configuration files for Windows
"
" _gvimrc File
" Maintained by: Marcin Kumorek
" kumeek@gmail.com
" http://kummar.pl
"
" Copy to ~/.gvimrc (linux) or ~/_gvimrc (windows)
"Forget compatibility with Vi. Who cares.
set nocompatible
@qmmr
qmmr / functions.js
Created August 30, 2012 20:27
JavaScript: Objects, Inheritance, Privacy and Stuff
function fairy (luckyNumber) {
return {
toString: function () {
return "The number you're looking for is " + luckyNumber;
}
};
}
function wizard (luckyNumber) {
var that = fairy (luckyNumber);
@qmmr
qmmr / uri.js
Created September 6, 2012 18:57 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@qmmr
qmmr / script.js
Created September 20, 2012 19:23
Avoid `console` errors in browsers that lack a console.
// Avoid `console` errors in browsers that lack a console.
if (!(window.console && console.log)) {
(function() {
var noop = function() {};
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];
var length = methods.length;
var console = window.console = {};
while (length--) {
console[methods[length]] = noop;
}
@qmmr
qmmr / helpers.js
Created October 3, 2012 06:27
JavaScript: isArray()
var isArray = function (obj) {
return obj && typeof obj === 'object' && obj.constructor === Array;
};
// doesn't detect if obj is array from other window or iFrame
var isArrayReally = function (obj) {
return Object.prototype.toString.apply(obj) === '[object Array]';
};