Skip to content

Instantly share code, notes, and snippets.

View KrofDrakula's full-sized avatar

Klemen Slavič KrofDrakula

View GitHub Profile
@KrofDrakula
KrofDrakula / keybase.md
Created March 24, 2014 18:37
keybase.md

Keybase proof

I hereby claim:

  • I am krofdrakula on github.
  • I am krofdrakula (https://keybase.io/krofdrakula) on keybase.
  • I have a public key whose fingerprint is EA86 6961 FFB8 0B24 F3A9 D194 F659 6008 D8F2 CFCA

To claim this, I am signing this object:

@KrofDrakula
KrofDrakula / .gitattributes
Created September 25, 2014 20:31
Explicit merge conflicts for specific path
DBBuild.php merge=merge-and-verify
@KrofDrakula
KrofDrakula / objectpool.js
Last active August 29, 2015 14:09
Object pooling implementation
function ObjectPool(Type) {
this.Type = Type;
this.available = [];
this.active = [];
}
ObjectPool.prototype.create = function() {
var args = [].slice.apply(arguments), self = this, inst, ret;
if (this.available.length == 0) {
var Temp = function() {};
@KrofDrakula
KrofDrakula / dither.js
Created November 22, 2014 00:16
Drag image example
(function(global) {
function Dither(container, width, height) {
this.container = container;
this.width = width;
this.height = height;
this.canvas = null;
this.image = null;
this.draw = this.draw.bind(this);
@KrofDrakula
KrofDrakula / curves.js
Created December 28, 2014 19:41
CSS Animation Bézier curve generator
(function(global) {
function extend(obj) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var name in source) if (source.hasOwnProperty(name))
obj[name] = source[name];
}
return obj;
}

Keybase proof

I hereby claim:

  • I am krofdrakula on github.
  • I am krofdrakula (https://keybase.io/krofdrakula) on keybase.
  • I have a public key whose fingerprint is A5B2 D08D 4333 E167 DB37 A7C0 6444 7954 106D 1D39

To claim this, I am signing this object:

@KrofDrakula
KrofDrakula / tmpl.js
Created June 5, 2015 16:59
Small templating function
// Use `<% ... %>` to execute blocks of JavaScript, `<%= ... %>` to write
// out the result of the embedded expression.
function tmpl(str, params) {
if (!str) return '';
function generateOutput(str) {
return " p.push('" + str.replace(/'/g, "\\'").split(/\r?\n/g).join("\\n');\n p.push('") + "');\n";
}
var fn;
// Leaving foo declaration global, since I don't know
// whether you need it outside the scope of the closure.
var foo = function() {};
(function() {
// The closure has private variables if declared
// with "var ...".
// Adding event utility functions for event handlers
// by John Resig.
// is there any reason why I can't use this pattern to replace .live
// in favour for .delegate?
(function ($) {
$.root = $(document); // hat tip: Cory Hart
// keep safe
$.fn._live = $.fn.live;
$.fn._die = $.fn.die;
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Overlap test</title>
</head>
<body>
<div class="page" style="background: yellow">
<h1>Test</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc auctor, augue vel commodo fermentum, urna dolor commodo lectus, vitae laoreet metus nunc sed turpis. Aliquam lorem dolor, faucibus ut convallis viverra, pulvinar eu nulla. Sed ac nulla eget est gravida lobortis vitae ac mauris. Vivamus fermentum lacus non nulla tristique eget ornare risus cursus. In at egestas risus. Sed vulputate fringilla dapibus. Aliquam erat volutpat. Sed rutrum lorem at dolor ullamcorper dignissim. In in metus leo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec laoreet, nulla ac rhoncus hendrerit, est justo cursus nisi, eget lobortis odio mauris eu arcu. Proin sagittis, lacus et egestas ultricies, nisl lacus sodales mi, ac commodo magna augue ut arcu. Aenean ac auc