Skip to content

Instantly share code, notes, and snippets.

@mattwarren
mattwarren / Explanation.md
Last active December 20, 2016 00:00
Sparkline SVG Optimisation

As per the spec:

  • The command letter can be eliminated on subsequent commands if the same command is used multiple times in a row (e.g., you can drop the second "L" in "M 100 200 L 200 100 L -100 -200" and use "M 100 200 L 200 100 -100 -200" instead).

Original SVG - 4.93 KB (5,049 bytes)

<svg version="1.1" baseProfile="full" width="500" height="50" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none">
  <line x1="0" y1="50" x2="500" y2="50" stroke="#f6f6f6" stroke-width="1" />
  <g fill="#008cba" stroke="none">
    <path d="M0 50 L0 41.7 L1 41.5 L2 42.2 L3 43.5 L4 44.3 L5 44.7 L6 45.2 L7 43.5 L8 44.3 L9 42.7 L10 42.3 L11 43.5 L12 44.5 L13 44.3 L14 44.3 L15 42.7 L16 43.0 L17 41.3 L18 40.8 L19 40.3 L20 41.8 L21 41.3 L22 42.8 L23 44.0 L24 42.7 L25 43.2 L26 43.8 L27 44.5 L28 43.2 L29 42.8 L30 44.0 L31 44.2 L32 43.3 L33 42.0 L34 42.5 L35 41.0 L36 39.5 L37 40.0 L38 40.5 L39 41.0 L40 40.7 L41 41.2 L42 41.7 L43 40.0 L44 41.0 L45 41.7 L46 41.0 L47 4
@jcarletto27
jcarletto27 / STLExporter.js
Last active September 23, 2020 13:09
updated Three.js STLExporter to export model including morphTargets
/**
* Based on https://github.com/mrdoob/three.js/blob/a72347515fa34e892f7a9bfa66a34fdc0df55954/examples/js/exporters/STLExporter.js
* Tested on r68 and r70
* @author jcarletto / https://github.com/jcarletto27
* @author kjlubick / https://github.com/kjlubick
* @author kovacsv / http://kovacsv.hu/
* @author mrdoob / http://mrdoob.com/
*/
THREE.STLExporter = function () {};
@carcinocron
carcinocron / debugger pause beforeunload
Last active April 25, 2024 16:48
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@NickCraver
NickCraver / jQuery.logHandlers.js
Created April 25, 2015 15:42
A simple jQuery plugin to print bound event handlers, including on parent elements
$.fn.logHandlers = function() {
var result = {};
this.parents().andSelf().each(function(_, e) {
var events = $._data(e, 'events') || {};
if ($.isEmptyObject(events)) return;
var cur = result[this.outerHTML.split($(this).html())[0]] = {};
Object.keys(events).forEach(function(k) {
cur[k] = events[k].map(function(ev) {
return ev.handler.toString();
});
@kjlubick
kjlubick / LICENSE
Last active May 1, 2022 22:26
Exports a THREE.js scene mesh to STL, making it suitable for 3d printing
The MIT License
Copyright © 2010-2016 three.js authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@kjlubick
kjlubick / .jshintrc
Last active August 29, 2015 14:03
JSHint for Sublime Text 3 settings
{
// Details: https://github.com/victorporof/Sublime-JSHint#using-your-own-jshintrc-options
// Example: https://github.com/jshint/jshint/blob/master/examples/.jshintrc
// Documentation: http://www.jshint.com/options/
"browser": true,
"devel": true,
"esnext": true,
"jquery":true,
"globals": {},
"globalstrict": false,
@mbostock
mbostock / .block
Last active May 14, 2016 08:02
Quicksort VI
license: gpl-3.0