Skip to content

Instantly share code, notes, and snippets.

View arika's full-sized avatar
🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️

akira yamada arika

🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️
View GitHub Profile
# Generate files:
#
# ```
# ruby client_auth_test.rb dir
# ```
#
# Run Apache HTTP server:
#
# ```
# apachectl -d dir -f httpd.conf -X
#!/usr/bin/env ruby
require 'rbconfig'
require 'shellwords'
require 'yaml'
require 'tmpdir'
def get_output(cmd)
IO.popen(cmd, 'r', &:read)
end
data=[
# [ id, input, expected ],
[ -1, "4", "4" ],
[ 0, "4*5+6&7|8", "44" ],
[ 1, "15*5", "75" ],
[ 2, "15+5", "20" ],
[ 3, "15&5", "5" ],
[ 4, "15|5", "15" ],
[ 5, "30*15*5", "2250" ],
[ 6, "30*15+5", "600" ],
@arika
arika / groonga.rb.diff
Created December 30, 2014 13:59
homebrew groonga.rb: enable mruby support and add tests.
diff --git a/Library/Formula/groonga.rb b/Library/Formula/groonga.rb
index 386e7ca..94e0a41 100644
--- a/Library/Formula/groonga.rb
+++ b/Library/Formula/groonga.rb
@@ -39,7 +39,7 @@ class Groonga < Formula
--prefix=#{prefix}
--with-zlib
--disable-zeromq
- --with-mruby
+ --enable-mruby
@arika
arika / groonga.rb.diff
Last active August 29, 2015 14:10
brew install groonga with mruby-support
with→enableの間違いを直すとonig-sourceの中身をbuildしてくれなくてコケるという流れ。
いきなりmake installでなく、いったんmakeすれば回避できるみたい。
diff --git a/Library/Formula/groonga.rb b/Library/Formula/groonga.rb
index 66a643d..441bddc 100644
--- a/Library/Formula/groonga.rb
+++ b/Library/Formula/groonga.rb
@@ -28,7 +28,7 @@ class Groonga < Formula
--prefix=#{prefix}
--with-zlib
@arika
arika / groonga-pry.rb
Last active August 29, 2015 14:08
run groonga command on pry
#!/usr/bin/env ruby
# encoding: utf-8
#
# Requirements:
# * groonga command
# * jq command <http://stedolan.github.io/jq/>
# * pry 0.10.x
#
# Configuration:
# * ~/.groonga-pryrc
# usage:
# ruby manual_import_migrations.rb ../path/to/project/db/migrate/**/*.rb
require 'optparse'
require 'fileutils'
require 'ripper'
def omit_pos(token)
if token.size == 3 &&
token[-1].is_a?(Array) && token[-1].size == 2 &&
@arika
arika / rails_erb_syntax_check.rb
Last active December 18, 2020 10:16
Rails(Action View) ERB template syntax checker
require 'action_view'
require 'ruby-beautify'
require 'ripper'
require 'tmpdir'
require 'fileutils'
require 'optparse'
def check_syntax(path, options = {})
erb = content(path)
code = ruby_code(erb)
@arika
arika / Rakefile
Last active December 31, 2015 10:39
three rake tasks for jekyll - scaffold new post, open last edited post, and open latest post.
require 'rubygems'
require 'fileutils'
require 'open-uri'
require 'pathname'
task :bundler do
require 'bundler/setup'
Bundler.require(:default)
require 'jekyll'
require './_libs/post_editor'
require 'tilt'
module Sprockets
class RemoveFontFaceExceptTheFirstOne < Tilt::Template
def prepare
end
def evaluate(context, locals, &block)
found = false
data.gsub(/^@font-face {[^}]*}/) do