Skip to content

Instantly share code, notes, and snippets.

Avatar

usa unak

View GitHub Profile
@unak
unak / helix.md
Last active Jul 6, 2018
Helixで左右どっちのボードにUSBケーブルを繋いでも使えるようにする
View helix.md

Helixのファームウェアは左手側のボードにUSBケーブルを繋ぐことを前提に作られている。 が、右手側に繋ぎたいことだってあるじゃん? というわけで、どっちに繋いでも使えるようにしてみた。

まず、自分の使ってるファームウェアのディレクトリ内(例えばkeyboards/helix/rev2/keymaps/default)のkeymap.cの冒頭付近、

extern keymap_config_t keymap_config;

の直前くらいに、

@unak
unak / allruby.cmd
Last active Dec 15, 2017
allruby script for Windows
View allruby.cmd
@echo off
C:\opt\ruby\bin\ruby.exe -x %~f0 %*
goto :EOF
#!ruby
require "yaml"
cache = File.join(File.dirname(__FILE__), "allruby.cache")
if File.exist?(cache)
rubies = YAML.load(File.read(cache))
else
View doukaku20.rb
MAZE = {
"0" => %w[1 6],
"1" => %w[0 7],
"2" => %w[3],
"3" => %w[2 4 9],
"4" => %w[3 5],
"5" => %w[4 B],
"6" => %w[0 C],
"7" => %w[1 8],
"8" => %w[7 9],
@unak
unak / pickup.rb
Created Aug 4, 2017
pickup configure arguments defined in ext/**/extconf.rb
View pickup.rb
require "ripper"
def show(meth, arg)
case meth
when "dir_config"
puts "--with-#{arg}-dir"
when "enable_config"
puts "--enable-#{arg}"
when "with_config"
puts "--with-#{arg}"
@unak
unak / memo.md
Last active Apr 22, 2017
Installation of local test mastodon
View memo.md

Installation of local test mastodon

手元の仮想マシンにテスト用のmastodonインスタンスを立ててみるための手順メモ。 なおこの手順でできるのはテスト用インスタンスなので外に出さないように。

Setup Ubuntu 16.04 on VMware

@unak
unak / healthcheck_process
Created Apr 16, 2017
munin plugin to check process existence for NetBSD, implemented with Ruby
View healthcheck_process
#!/usr/local/bin/ruby
PS = "/bin/ps"
keys = ENV.keys.grep(/^process_\d+$/).sort_by{|e| e.split(/_/, 2).last.to_i}
arg = ARGV.shift
if arg == "autoconf"
if keys.empty?
@unak
unak / rake_did_you_mean.rb
Created Mar 28, 2017
Show candidate when specified task name is not valid
View rake_did_you_mean.rb
begin
require "did_you_mean"
module Rake::TaskManager
def [](task_name, scopes=nil)
task_name = task_name.to_s
self.lookup(task_name, scopes) or
enhance_with_matching_rule(task_name) or
synthesize_file_task(task_name) or
(STDERR.puts "Don't know how to build task '#{task_name}' (see --tasks)";
candidates = DidYouMean::SpellChecker.new(dictionary: @tasks.keys).correct(task_name);
@unak
unak / test-bundled-gem.rb
Created Dec 2, 2016
How to test bundled gems?
View test-bundled-gem.rb
require "rubygems"
srcdir = File.expand_path("YOUR RUBY SOURCE DIRECTORY")
Dir.glob(File.join(srcdir, "gems", "*.gem")) do |gem|
tmp = File.basename(gem, ".gem").split(/-/)
version = tmp.pop
name = tmp.join('-')
spec = Gem::Specification.find{|s| s.name == name && s.version.version == version}
View drawcmd.rb
if ARGV.size != 1
warn "Usage: ruby #$0 <image file>"
exit
end
image_file = ARGV.shift.encode("utf-16le")
require "fiddle/import"
module Kernel32
View tmp.rb
RSTRLEN_MAX = 50
N = 10000
# user system total real
# ana1 0.109000 0.000000 0.109000 ( 0.104961)
# ana2 0.078000 0.000000 0.078000 ( 0.074173)
require 'benchmark'
def ana1(s1, s2)
You can’t perform that action at this time.