Skip to content

Instantly share code, notes, and snippets.

View KrofDrakula's full-sized avatar

Klemen Slavič KrofDrakula

View GitHub Profile
@KrofDrakula
KrofDrakula / dabblet.css
Created January 7, 2012 21:04
Untitled
body { font-size: 120%; }
td, th { font: inherit; }
td { padding: 0.2em 0.5em; border: 1px solid black; }
@media screen and (max-width: 240px) {
table, tbody, tr, td { display: block; }
tr:nth-child(2n) { background: #ccc; }
}
@KrofDrakula
KrofDrakula / email-validation.js
Created January 25, 2012 07:37
Email validation? Seriously?
//
// Email address must be of form [email protected] ... in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
function isValidEmail(s)
{
if (isEmpty(s)) return false;
// is s whitespace?
<html>
<head>
<title>Canvas bootstrap</title>
<style>body { text-align: center; } canvas { border: 1px solid black; margin: auto;}</style>
<script src="raf.js"></script>
</head>
<body>
<canvas id="canvas" width="500" height="500"></canvas>
<script>
var helpers = {
// Scripting Chrome for awesome
// This script finds all matching history entries
// in the chrome://chrome/history/ panel and turns
// the checkboxes on so you don't have to click through
// all of them.
// Retrieve all entries from the currently displayed
// history list (use the Search history to limit your
// list first).
@KrofDrakula
KrofDrakula / rbf.js
Created June 15, 2012 11:29
Drop the bass.
if((new Date).getDay()-5==0)location='http://is.gd/3VyqL2'
@KrofDrakula
KrofDrakula / WTF.js
Created June 26, 2012 13:18
Javascript, What The Fuck?!
// Outputs 0
console.log(Math.min(null, 1234));
// Outputs NaN
console.log(Math.min('null', 1234));
// Outputs 1
console.log(Math.min('1', 1234));
// DAFUQ?
@KrofDrakula
KrofDrakula / ConsoleLogger.js
Last active October 6, 2015 15:58
A `console.*` logger and `window.onerror` handler for mobile devices
(function() {
var ZINDEX_MAX = 2147483647;
if (window === window.top) {
// Host page code
var wrapper = document.createElement('div');
wrapper.style.cssText = [
'display:block; position: fixed; z-index: ' + ZINDEX_MAX + ';',
'left: 0; bottom: 0; right: 0; box-sizing: border-box;',
'background: rgba(0,0,0,0.8); color: white; font-size: 8px;',
@KrofDrakula
KrofDrakula / index.md
Created September 5, 2012 16:53
WebKit image rendering performance

Rendering performance on WebKit

Please send any feedback on this article to Klemen Slavič

UPDATE: I'm currently in the process of updating the article, as my assumptions about the inner workings of WebKit are incorrect. I will update this article with the relevant facts and provide concrete information in place of my guesstimates below.

I've recently stumbled upon an interesting discovery regarding image rendering performance in most WebKit browsers. Namely, I've been developing a sprite animation component to implement a GIF animation replacement with better compression and performance, where I noticed that some animations appeared to be janky when using multi-frame spritesheets and clipping rectangles. Here's what I found out.

But first, a quick rundown of the basic functioning of the WebKit engine as I understand it.

[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold

Install node. Install grunt globally:

npm install grunt -g

Go to the project directory and run:

grunt default watch