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
paulkaplan / README.md
Created Jan 10, 2018 — forked from eweitnauer/README.md
Dominant Baseline Style
View README.md

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
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) {
existingStatsElement.parentNode.removeChild(existingStatsElement);
@paulkaplan
paulkaplan / ascii_stl_writer.js
Last active Aug 29, 2015
ascii_stl_writer.js
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
paulkaplan / binary_stl_writer.js
Last active Jun 24, 2018
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
paulkaplan / yosemite_fixes.sh
Created Oct 18, 2014
Fixing dev environment on Yosemite
View yosemite_fixes.sh
# xcode command line tools are gone
# reinstall them
xcode-select --install
# Pow is broken, update to 0.5.0
curl get.pow.cx | sh
# PG is broken, Yosemite removes needed dirs
# http://stackoverflow.com/questions/25970132/pg-tblspc-missing-after-installation-of-os-x-yosemite-beta
mkdir /usr/local/var/postgres/pg_tblspc
@paulkaplan
paulkaplan / text_input.coffee
Last active Aug 29, 2015
React input component in Coffeescript
View text_input.coffee
TextInput = React.createClass
propTypes:
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
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 www.ladyada.net and adafruit.com
for more tutorials!
@paulkaplan
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 = @"https://api.spark.io/v1/devices";
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=%@",
sparkApi,
deviceId,
@paulkaplan
paulkaplan / demo.html
Last active Aug 29, 2015
Tiny jQuery plugin to make walkthroughs
View demo.html
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="walkthrough.js"></script>
<link rel="stylesheet" href="walkthrough.css" />
<body>
<div class='walkthrough-container'>
<div class="walkthrough-steps">
<div
@paulkaplan
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.