Skip to content

Instantly share code, notes, and snippets.

Hiroaki Nakamura hnakamur

Block or report user

Report or block hnakamur

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
@hnakamur
hnakamur / gist:9428153
Created Mar 8, 2014
bashスクリプトをシェルから実行するときの引数のエスケープ
View gist:9428153
$ cat echo_arg.sh
#!/bin/bash
echo arg=$1
$ ./echo_arg.sh "$6$"
arg=$
$ ./echo_arg.sh '$6$'
arg=$6$
@hnakamur
hnakamur / setup.sh
Created Apr 26, 2014
(WIP) my mavericks setup script
View setup.sh
xcode-select --install
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@hnakamur
hnakamur / index.html
Last active Aug 29, 2015
Firefox hangs with SVG path getTotalLength for some path with two cubic bezier segments. try http://bl.ocks.org/hnakamur/bc26a6fa7d7b8d9dc795
View index.html
<!DOCTYPE html>
<head>
<meta charset='utf-8'>
</head>
<body>
<div id='example'>
<svg width="300" height="300">
<path id="path1" d="M229.99999999999994,196.66666666666666C229.99999999999997,213.33333333333331,229.99999999999997,246.66666666666666,241.66666666666663,263.3333333333333" stroke="black" fill="none"/>
<path id="path2" d="M241.66666666666663,263.3333333333333C253.33333333333331,280,276.66666666666663,280,288.3333333333333,280" stroke="black" fill="none"/>
<path id="path3" d="M229.99999999999994,196.66666666666666C229.99999999999997,213.33333333333331,229.99999999999997,246.66666666666666,241.66666666666663,263.3333333333333C253.33333333333331,280,276.66666666666663,280,288.3333333333333,280" stroke="black" fill="none"/>
@hnakamur
hnakamur / index.html
Created Jul 26, 2014
SVG path getTotalLength() in Firefox returns 0 or a wrong large value for some cubic bezier segments. try http://bl.ocks.org/hnakamur/f203e1cb6adedb56eca8
View index.html
<!DOCTYPE html>
<head>
<meta charset='utf-8'>
</head>
<body>
<div id='example'>
<svg width="300" height="300">
<path id="path1" d="M229.99999999999994,196.66666666666666C229.99999999999997,213.33333333333331,229.99999999999997,246.66666666666666,241.66666666666663,263.3333333333333" stroke="black" fill="none"/>
<path id="path2" d="M241.66666666666663,263.3333333333333C253.33333333333331,280,276.66666666666663,280,288.3333333333333,280" stroke="black" fill="none"/>
</svg>
@hnakamur
hnakamur / bezier-curve.js
Created Jul 31, 2014
offseted marker on cubic bezier curve example
View bezier-curve.js
(function(root) {
function BezierCurve(points) {
this.xs = points.map(function(point) { return point.x; });
this.ys = points.map(function(point) { return point.y; });
}
// LUT for binomial coefficient arrays per curve order 'n'
var binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
@hnakamur
hnakamur / localhost.yml
Last active Aug 29, 2015
Ansible localhost playbook for my MacBook
View localhost.yml
- hosts: localhost
connection: local
gather_facts: yes
sudo: no
roles:
- hnakamur.osx-defaults
- hnakamur.homebrew-packages
- hnakamur.homebrew-cask-packages
- hnakamur.osx-login-shell
- hnakamur.oh-my-zsh
@hnakamur
hnakamur / bundle.js
Created Sep 6, 2014
An example of drawing intersections of a cubic bezier curve and an elliptic arc
View bundle.js
!function(n){function t(r){if(e[r])return e[r].exports;var i=e[r]={exports:{},id:r,loaded:!1};return n[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var e={};return t.m=n,t.c=e,t.p="dist/",t(0)}([function(n,t,e){function r(n){n.x=c.event.x,n.y=c.event.y,c.select(this).attr({cx:n.x,cy:n.y}),n.pathElem.attr("d",i),n.controlLineElem&&n.controlLineElem.attr("d",u),b.selectAll("text.handle-text.path"+n.pathID+".p"+(n.handleID+1)).attr({x:n.x,y:n.y}).text(o(n,n.handleID)),s()}function i(n){var t=n.points;switch(n.type){case"L":return["M",t[0].x," ",t[0].y," ",t[1].x," ",t[1].y].join("");case"Q":return["M",t[0].x," ",t[0].y,"Q",t[1].x," ",t[1].y," ",t[2].x," ",t[2].y].join("");case"C":return["M",t[0].x," ",t[0].y,"C",t[1].x," ",t[1].y," ",t[2].x," ",t[2].y," ",t[3].x," ",t[3].y].join("");case"A":return"M"+n.x1+" "+n.y1+"A"+n.rx+" "+n.ry+" "+n.xAxisRotation+" "+n.largeArcFlag+" "+n.sweepFlag+" "+n.x2+" "+n.y2}}function u(n){var t=[];return n.points.forEach(function(n){t.push(n.x),t.push(n.y)}),"M"+t.join(" "
@hnakamur
hnakamur / README.md
Last active Aug 29, 2015
An example for drawing an arrowhead at the intersection of a bezier curve and a circle using d3.js
@hnakamur
hnakamur / spawn_ls_promise.lua
Created Sep 6, 2014
An example using uv.spawn with lua_promise
View spawn_ls_promise.lua
-- An example using uv.spawn with Promise.
-- (c) 2014 Hiroaki Nakamura
-- MIT license
--
-- Used libraries
-- * luv: https://github.com/luvit/luv
-- * lua_promise: https://github.com/friesencr/lua_promise
local uv = require("luv")
require("Promise")
You can’t perform that action at this time.