Skip to content

Instantly share code, notes, and snippets.

@andrijac
andrijac / gist:1296731
Created October 18, 2011 21:08 — forked from dshaw/gist:378192
(function(window,document,undefined){ ... })(this,this.document);
// everyone's new favorite closure pattern:
(function(window,document,undefined){ ... })(this,this.document);
// when minified:
(function(w,d,u){ ... })(this,this.document);
// which means all uses of window/document/undefined inside the closure
// will be single-lettered, so big gains in minification.
// it also will speed up scope chain traversal a tiny tiny little bit.
@andrijac
andrijac / LICENSE.txt
Created May 16, 2012 12:00 — forked from atk/LICENSE.txt
polyfill an ES5-compatible Array.prototype.indexOf
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Alex Kloss <alexthkloss@web.de>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
var wl = function(s) {
var dw = function(s){document.write(s);},
spaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
dw(!s ? 'false!!!' : (s).toString());
dw(('<br />').toString());
for(var i in s) {
if((s[i]).toString().indexOf('function') !== -1) {
@andrijac
andrijac / select.js
Created August 13, 2012 12:51
select element in jquery, reading values
// selected index in select (dropdown)
$.fn.selectedIndex = function () {
var index = 0;
this.each(function () {
index = +$(this).prop('selectedIndex');
return false;
});
return index;
};
@andrijac
andrijac / format.js
Created August 14, 2012 10:07
.net like format function for strings in javascript
var formatFunc = function format() {
// slice 1st parameter which is pattern
var args = Array.prototype.slice.call(arguments, 1),
pattern = arguments[0];
return pattern.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined' ? args[number] : match;
});
};
@andrijac
andrijac / disableButtons.js
Created August 15, 2012 11:31
Disable all bootstrap buttons, jquery plugin
$.fn.disableButton = function () {
this.each(function (index, item) {
if (this.tagName === 'A') {
$(this).attr('disabled', 'disabled');
}
if (this.tagName === 'BUTTON') {
$(this).addClass('disabled');
}
});
};
@andrijac
andrijac / killweb.bat
Created August 16, 2012 11:52
kill web
kill -f webdev.webserver webdev.webserver40 firefox iexplore iisexpress
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
iisreset
sync
@andrijac
andrijac / createProperty.js
Created August 17, 2012 08:00
create property in javascript, cross browser, createProperty function
function createProperty(config) {
var options = { initValue: null, setter: null, getter: null },
_config = $.extend(options, config),
_value = _config.initValue,
context;
return function (value) {
if (value === undefined) {
if (_config.getter && typeof _config.getter === "function") {
context = { value: _value };
return config.getter(context);
@andrijac
andrijac / test_template.html
Created August 29, 2012 23:27
JS Test template
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/qunit/qunit-git.css" />
<title></title>
</head>
<body>
<div id="qunit"></div>
<!---------- scripts ----------------->
@andrijac
andrijac / test.c
Created September 8, 2012 20:39
testing
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
//#include<iostream>
void wl(int);
void main()
{
int i, j;