Skip to content

Instantly share code, notes, and snippets.

View hnakamur's full-sized avatar

Hiroaki Nakamura hnakamur

View GitHub Profile
@hnakamur
hnakamur / bundle.js
Created September 6, 2014 16:17
An example of drawing intersections of a cubic bezier curve and an elliptic arc
!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(" "
Hello, {{ name }}
@hnakamur
hnakamur / main.go
Created September 9, 2014 22:22
example using github.com/danryan/go-group/os/group
package main
import (
"fmt"
"github.com/danryan/go-group/os/group"
)
func main() {
g, err := group.CurrentGroup()
@hnakamur
hnakamur / dig_domain_and_elb.rb
Created September 15, 2014 03:09
ドメインとELBのIPアドレスを毎秒表示するRubyスクリプト。Route53でALIASでELBのドメインを設定した時用。domainとelb_domainの値を書き換えて使ってください。
#!/usr/bin/env ruby
# (c) 2014 Hioraki Nakamura
# MIT License
domain = "_YOUR_DOMAIN_HERE_"
elb_domain = "_YOUR_ELB_HOSTNAME_HERE_.ap-northeast-1.elb.amazonaws.com"
def get_ttl_and_ip(domain)
ttl_and_ips = []
IO.popen(["dig", domain], "r") do |io|
while line = io.gets
@hnakamur
hnakamur / ipnets.go
Created January 25, 2015 03:07
List pairs of IPv4 address and netmask on Windows using Go (MIT License)
package main
import (
"fmt"
"net"
"os"
"syscall"
"unsafe"
)
@hnakamur
hnakamur / addLang.js
Created January 31, 2015 10:19
A JavaScript.NET script for adding Japanese language to Modern.IE 32bit Windows 8 (MIT License)
import System.Windows.Automation;
import System.Threading;
import System.Diagnostics;
Process.Start("C:\\Windows\\system32\\control.exe");
function waitForTopLevelWindowWithName(name) {
var cond = new PropertyCondition(AutomationElement.NameProperty, name);
while (true) {
var win = AutomationElement.RootElement.FindFirst(TreeScope.Children, cond);
@hnakamur
hnakamur / private.xml
Last active August 29, 2015 14:19
My key mappings for Karabiner to activate apps with shortcut keys
<?xml version="1.0"?>
<root>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_APP_Firefox</name>
<url type="file">/Applications/Firefox.app</url>
</vkopenurldef>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_APP_Finder</name>
<url type="file">/System/Library/CoreServices/Finder.app</url>
@hnakamur
hnakamur / private.xml
Created April 14, 2015 01:52
Karabinerで英数→英数⌘, ⌘→⌥, ⌥→fnと置き換える設定
<?xml version="1.0" encoding="UTF-8"?>
<root>
<item>
<name>Map EISUU to EISUU and ⌘</name>
<identifier>private.eisuu</identifier>
<autogen>
__KeyToKey__
KeyCode::JIS_EISUU,
KeyCode::JIS_EISUU,
KeyCode::COMMAND_L
@hnakamur
hnakamur / install_docker.sh
Last active August 29, 2015 14:19
shell script for installing latest docker and docker-compose on CentOS7 (MIT license)
#!/bin/sh
set -e
sudo yum install -y git xz
if [ ! -f /usr/bin/docker ]; then
sudo curl -L -o /usr/bin/docker https://get.docker.com/builds/Linux/x86_64/docker-latest
sudo chmod +x /usr/bin/docker
fi
@hnakamur
hnakamur / gist:748dd8bd7730eb48fa5e
Last active August 29, 2015 14:20
cgoroonga import error on docker
---> 9152e30f13a7
Step 8 : RUN export GOPATH=/usr/local/src/go && $GOPATH/src/github.com/hnakamur/cgoroonga/examples/import_wikipedia/import_wikipedia -d /usr/local/var/groonga/db/wikipedia.db /usr/local/src/wikipedia-data/jawiki-20150402-pages-articles4.xml.bz2
---> Running in 9fbf9ddaf335
fatal error: unexpected signal during runtime execution
[signal 0x7 code=0x2 addr=0x7f5668ee489f pc=0x7f56e8b44005]
runtime stack:
runtime.gothrow(0x569850, 0x2a)
/usr/local/go/src/runtime/panic.go:503 +0x8e
runtime.sigpanic()