Skip to content

Instantly share code, notes, and snippets.

Paul Kaplan paulkaplan

Block or report user

Report or block paulkaplan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
paulkaplan /
Created Jan 10, 2018 — forked from eweitnauer/
Dominant Baseline Style

Demonstrates the effect of dominant baseline for each of its possible values on text positioning in an SVG.

Each browser/ mobile browser seems to handle these a bit differently. Here are some issues:

  • Retrieving bounding boxes only works correctly after the font is loaded (and there is no easy way to find out when this happens)
  • The bounding box width does not reflect the actual extent of a text, but how far it advances the cursor. That means that in an italic letter 'f' in many fonts, part of the f will actually lie outside of the bounding box
  • The baseline-shift style does not work in FF
  • dominant-baseline values are interpreted different among browsers

All in all its best just use 'alphabetical' (which is consistent across browsers) and do any further vertical positioning by manually by using the x,y or dx,dy or the transform attributes. Also, if one needs to find out about the actual bounds of a text, one cannot rely on the getBBox() or the getBoundingClientRect() DOM methods, but has to use

paulkaplan / bookmarklet.js
Created Oct 23, 2015
Customized stats.js bookmarklet
View bookmarklet.js
javascript:(function() {
var script = document.createElement('script');
script.onload = function() {
/* Remove existing stats if it exists */
var existingStatsElement = document.getElementById('stats');
if (existingStatsElement) {
paulkaplan / ascii_stl_writer.js
Last active Nov 10, 2019
View ascii_stl_writer.js
// Written by Paul Kaplan
var AsciiStlWriter = (function() {
// ASCI STL files
function stringifyVector(vec){
return ""+vec.x+" "+vec.y+" "+vec.z;
function stringifyVertex(vec){
paulkaplan / binary_stl_writer.js
Last active Nov 10, 2019
Writing binary and ascii STL files in Javascript
View binary_stl_writer.js
// Written by Paul Kaplan
var BinaryStlWriter = (function() {
var that = {};
var writeVector = function(dataview, offset, vector, isLittleEndian) {
offset = writeFloat(dataview, offset, vector.x, isLittleEndian);
offset = writeFloat(dataview, offset, vector.y, isLittleEndian);
return writeFloat(dataview, offset, vector.z, isLittleEndian);
paulkaplan /
Created Oct 18, 2014
Fixing dev environment on Yosemite
# xcode command line tools are gone
# reinstall them
xcode-select --install
# Pow is broken, update to 0.5.0
curl | sh
# PG is broken, Yosemite removes needed dirs
mkdir /usr/local/var/postgres/pg_tblspc
paulkaplan /
Last active Aug 29, 2015
React input component in Coffeescript
TextInput = React.createClass
className: React.PropTypes.string,
id: React.PropTypes.string,
placeholder: React.PropTypes.string,
onSave: React.PropTypes.func.isRequired,
value: React.PropTypes.string
getInitialState: ->
value: @props.value or ''
paulkaplan / arduino_ir_receiver.ino
Last active Aug 29, 2015
Record incoming IR pulses with an IR Receiver on an Arduino
View arduino_ir_receiver.ino
/* Raw IR decoder sketch!
This sketch/program uses the Arduno and a PNA4602 to
decode IR received. This can be used to make a IR receiver
(by looking for a particular code)
or transmitter (by pulsing an IR LED at ~38KHz for the
durations detected
Code is public domain, check out and
for more tutorials!
paulkaplan / spark-request.m
Last active Aug 29, 2015
Getting started with remote function calls on Spark Core
View spark-request.m
- (void) makeSparkRequest {
NSString *sparkApi = @"";
NSString *deviceId = @"<YOUR_DEVICE_ID>";
NSString *functionName = @"<YOUR_FUNCTION_NAME>"; // registered to cloud using Spark.function("FUNCTION_NAME", FUNCTION);
NSString *accessToken = @"<YOUR_ACCESS_TOKEN>";
NSURL *url = [NSURL URLWithString: [NSString stringWithFormat:@"%@/%@/%@\?access_token=%@",
paulkaplan / demo.html
Last active Aug 29, 2015
Tiny jQuery plugin to make walkthroughs
View demo.html
<script src=""></script>
<script src="walkthrough.js"></script>
<link rel="stylesheet" href="walkthrough.css" />
<div class='walkthrough-container'>
<div class="walkthrough-steps">
paulkaplan / Shapeoko_inch.pp
Created Jan 10, 2014
Vectric configuration file for Shapeoko (inch, with arcs)
View Shapeoko_inch.pp
+ Vectric machine output configuration file
+ History
+ Who When What
+ ======== ========== ===========================
You can’t perform that action at this time.