Skip to content

Instantly share code, notes, and snippets.

View KrofDrakula's full-sized avatar

Klemen Slavič KrofDrakula

View GitHub Profile
// shorter vars for brevity
var a = image.naturalWidth,
b = image.naturalHeight,
c = maxImageWidth,
d = maxImageHeight,
r1 = a / b, // image aspect ratio
r2 = c / d; // container aspect ratio
// determine which dimension is the limiting factor
// according to the aspect ratio comparison and
@KrofDrakula
KrofDrakula / .gitattributes
Created September 25, 2014 20:31
Explicit merge conflicts for specific path
DBBuild.php merge=merge-and-verify
@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:

[alias]
history = log --graph --pretty=format:'%C(yellow)%h%Creset %C(bold blue)%an%Creset %Cgreen(%cr)%Creset: %s'
@KrofDrakula
KrofDrakula / index.md
Created October 24, 2013 21:54
Reproduction steps for Chrome dev tools console bug
  1. Open http://jsbin.com/EQoBeV/2.
  2. Open dev tools
  3. Choose 2 from the dropdown list to select the iframe's window context
  4. Type window.myVariable – it should be set to 3 (like it says in the iframe content)
  5. Reload page
  6. Do steps 3 and 4 again – there is no such variable
  7. Verify that it is inside the iframe: window.frames[1].myVariable outputs 3

This shows that the dev console breaks after reloading the page with the dev console open. The problem does resolve if you close and re-open the dev console.

@KrofDrakula
KrofDrakula / raf.js
Last active December 15, 2015 20:19
Due to a bug in the native `requestAnimationFrame` function running inside `<iframe>` elements on iOS 6, I've decided to write up a custom function that implements a blacklist. Use this snippet and use `nextFrame` and `cancelFrame` on the `window` object to use this workaround with the same method signature as the spec. I've avoided overriding t…
// requestAnimationFrame implementation as a custom function to allow blacklisting
// devices with broken implementation. Currently needs timer-based fallbacks for iOS 6.x for
// code running inside <iframe> elements.
// Uses polyfills based on http://paulirish.com/2011/requestanimationframe-for-smart-animating/
(function() {
var blacklisted = /iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent),
lastTime = 0,
nativeRequest = window.requestAnimationFrame || null,
nativeCancel = window.cancelAnimationFrame || null;
@KrofDrakula
KrofDrakula / gist:5261852
Last active December 15, 2015 12:39
Dobil vprašanje na LinkedIn za začetnike programiranja, pa sem se odločil napisati daljši odgovor, ker pogosto prejemam podobna vprašanja.

Vprašanje:

Zdravo,

Sem rekel, da se bom kar na tebe obrnil, ker si mi zdiš najbolj primeren za to vprašanje.

Sem mal pregledal zadevo in sedaj imam sledeči spisek:

  • Ruby
  • Java
[alias]
st = status
ci = commit
br = branch
co = checkout
history = log --graph --pretty=format:'%C(yellow)%h%Creset %C(bold blue)%an%Creset %Cgreen(%cr)%Creset: %s'
update = !git stash && git fetch && git rebase && git stash pop
@KrofDrakula
KrofDrakula / gist:4443227
Last active December 10, 2015 13:48
Problem: visit every pixel of a 2-dimensional texture using a single sequence generator

Declare a 2D texture with integer coordinates:

 ______w_______
|(0,0)         |
|              |
|              |h
|              |
|_____(w-1,h-1)|