Skip to content

Instantly share code, notes, and snippets.

@lakenen
lakenen / index.html
Last active April 6, 2024 01:28 — forked from abeppu/index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://d3js.org/d3.v2.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<div id="chart"></div>
@lakenen
lakenen / importNode.js
Created March 14, 2013 21:55
document.importNode shim for IE <= 9. Started with http://stackoverflow.com/questions/1811116/ie-support-for-dom-importnode/9883539#9883539, modified to fix issues (http://stackoverflow.com/questions/14593520/ie9-importing-inline-svg-image-elements-broken) with importing image nodes and other nodes with namespaced:attributes
function importNode(node, allChildren, doc) {
var a, i, il;
doc = doc || document;
try {
return doc.importNode(node, allChildren);
} catch (e) {
switch (node.nodeType) {
case document.ELEMENT_NODE:
var newNode = doc.createElementNS(node.namespaceURI, node.nodeName);
if (node.attributes && node.attributes.length > 0) {
@lakenen
lakenen / detectanimation.js
Created June 28, 2012 17:17
JavaScript animated GIF detection!
function isAnimatedGif(src, cb) {
var request = new XMLHttpRequest();
request.open('GET', src, true);
request.responseType = 'arraybuffer';
request.addEventListener('load', function () {
var arr = new Uint8Array(request.response),
i, len, length = arr.length, frames = 0;
// make sure it's a gif (GIF8)
if (arr[0] !== 0x47 || arr[1] !== 0x49 ||
@lakenen
lakenen / getTextBoundingRect.js
Created December 3, 2012 02:26
Get cursor or text position in pixels for input element
// @author Rob W http://stackoverflow.com/users/938089/rob-w
// @name getTextBoundingRect
// @param input Required HTMLElement with `value` attribute
// @param selectionStart Optional number: Start offset. Default 0
// @param selectionEnd Optional number: End offset. Default selectionStart
// @param debug Optional boolean. If true, the created test layer
// will not be removed.
function getTextBoundingRect(input, selectionStart, selectionEnd, debug) {
// Basic parameter validation
if(!input || !('value' in input)) return input;
@lakenen
lakenen / CSSMatrix-example.js
Created March 27, 2013 19:23
CSSMatrix examples
// include https://github.com/camupod/CSSMatrix/blob/browserified/CSSMatrix.js
// create a matrix from a CSS matrix transform string
var matrix1 = new CSSMatrix('matrix(1, 2, 3, 4, 5, 6)');
var matrix2 = new CSSMatrix('matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)');
// create a matrix from matrix values
var matrix3 = new CSSMatrix(1, 2, 3, 4, 5, 6);
var matrix4 = new CSSMatrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
@lakenen
lakenen / teledraw-canvas-layers.html
Created January 17, 2017 20:29
Teledraw Canvas example with synced layers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Teledraw Canvas Example</title>
<style type="text/css">
html, body {
background: #888;
}
@lakenen
lakenen / build.sh
Last active March 15, 2016 21:05
Emscripten JS/C++ Proxy Example (http://stackoverflow.com/a/16725147/494954)
#!/bin/bash
emcc helloworld.cpp -o helloworld.js \
-s EXPORTED_FUNCTIONS="['_HW_constructor','_HW_destructor','_HW_setX','_HW_getX']"
cat helloworld-proxy.js >> helloworld.js
@lakenen
lakenen / page-svg.css
Created March 27, 2013 06:22
Crocodoc 3D Demo #4
/* ... */
.crocodoc-page-svg {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
@lakenen
lakenen / page-transitions.css
Last active December 15, 2015 11:19
Crocodoc 3D Demo #2
/* ... */
.page-transitions .page-layer {
/* cheating a bit and adding a transition to "all" properties */
transition: all 0.3s;
}
.page-layer:first-child,
.page-exploded .page-layer {
background: rgba(255,255,255,0.03);
@lakenen
lakenen / demo1.html
Last active December 15, 2015 11:19
Crocodoc 3D Demo #1
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="CSSMatrix.js"></script>
<style>
body {
background-color: #282828;