Skip to content

Instantly share code, notes, and snippets.

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

akira yamada arika

🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️
View GitHub Profile
module GemDepPatch_
def to_specs
#super.select {|spec| spec.full_name != 'activesupport-5.1.2' }
super.sort_by {|spec| spec.activated? ? -1 : 1 }
end
end
Gem::Dependency.prepend(GemDepPatch_)
# 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
#!/usr/bin/ruby
require 'origami'
include Origami
pdf = PDF.read(ARGV.first)
pdf.pages.each do |page|
xobjs = page.Resources[:XObject]
xname = xobjs.keys.first
obj = xobjs[xname].solve
open("new-image.jpg", "r") do |i|
@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
@arika
arika / similar_posts.rb
Created July 28, 2012 05:19
Jekyll/Octopressの類似文書検索をGroongaで行う
# encoding: utf-8
#
# Groongaの類似文書検索機能を使って類似記事を抽出する。
require 'tmpdir'
require 'groonga'
module Jekyll
class Site
alias process_without_groonga process
#!/usr/bin/env ruby
# encoding: utf-8
require 'mini_magick'
require 'origami'
include Origami
def fixup!(pdf)
pdf.root_objects.each do |obj|
next unless obj.is_a?(Graphics::ImageXObject)
@arika
arika / jekyll-patch.rb
Created April 5, 2012 05:19
improve process time of octopress/jekyll (2nd)
# based lib/jekyll/site.rb of jekyll 0.11.0
module Jekyll
class Site
class PostList < Array
def sort
self.class.new(super)
end
def next(obj)
setup_index_cache
@arika
arika / jekyll-patch.rb
Created March 29, 2012 09:42
improve process time of octopress/jekyll
# based lib/jekyll/site.rb of jekyll 0.11.0
module Jekyll
class Site
class PostList < Array
def index(obj)
unless @hash
@hash = {}
each_with_index do |post, idx|
@hash[post.object_id] = idx
end