Skip to content

Instantly share code, notes, and snippets.

require 'English'
require 'epub/parser'
require 'epub/parser/cfi'
require 'nokogiri'
def usage
<<EOS
USAGE:
ruby #{$PROGRAM_NAME} ELEMENT EPUB
{
"manifest_version": 2,
"name": "BiB/i",
"version": "1.0",
"applications": {
"gecko": {
"id": "KitaitiMakoto@gmail.com"
}
},
"permissions": [
<!doctype html>
<title>sprite</title>
<style>
div {
width: 64px;
height: 81px;
margin: 3em;
background-repeat: no-repeat;
background-image: url("senior-santa.png");
background-size: auto 100%;
table_create Apehuci TABLE_HASH_KEY ShortText
column_create Apehuci content COLUMN_SCALAR Text
column_create Apehuci tags COLUMN_VECTOR ShortText
column_create Apehuci title COLUMN_SCALAR ShortText
table_create ApehuciTerms TABLE_PAT_KEY ShortText --default_tokenizer TokenMecab --normalizer NormalizerAuto
load --table Apehuci
[
["_key","content","tags","title"],
@KitaitiMakoto
KitaitiMakoto / file0.rb
Created January 24, 2016 16:46
Middlemanで「変更なし」「作成」「削除」「変更」の状態を取る ref: http://qiita.com/KitaitiMakoto/items/ca3792f75270b533d37c
class CatchChange < ::Middleman::Extension
def before_build(builder)
@mode = mode = Hash.new {|mode, event_type| mode[event_type] = []}
builder.on_build_event do |event_type, target, extra|
p event_type # => :identicalなど
p target # => #<Pathname:build/2015/11/06.amp.html>など、出力先のパス
p extra # => nil 「on_build_event」では常にnil
case event_type
module Itamae
module Resource
class SecurityContext < Base
define_attribute :action, default: :nothing
define_attribute :path, type: [String], default_name: true
define_attribute :recursive, type: [TrueClass, FalseClass], default: false
def action_restore(options)
cmd = ['restorecon', attributes.path]
cmd << '-R' if attributes.recursive
@KitaitiMakoto
KitaitiMakoto / ItamaeでSELinuxセキュリティコンテクストを管理したい.markdown
Created January 5, 2016 04:10
ItamaeでSELinuxセキュリティコンテクストを管理したい
# coding: utf-8
gem 'epub-parser', '>= 0.2.4'
gem 'epub-maker', '>= 0.0.2'
require 'English'
require 'epub/maker'
require 'epub/parser/cfi'
require 'nokogiri/xml/range'
TARGET_RELEASE_IDENTIFIER = 'urn:uuid:14eadcd9-214a-4f45-9623-d8ac54f22af7@2015-12-04T09:00:00Z'
@KitaitiMakoto
KitaitiMakoto / catalog.json
Last active November 15, 2015 12:17
Test data for Droonga plugin tutorial
{
"version": 2,
"effectiveDate": "2013-09-01T00:00:00Z",
"datasets": {
"Default": {
"nWorkers": 4,
"plugins": ["groonga", "crud", "search", "dump", "status"],
"schema": {
"Store": {
"type": "Hash",
# coding: utf-8
require 'kuromoji'
while title = ARGF.gets
result = Kuromoji.tokenize(title).to_a
puts result.sort {|word1, word2|
word1_chars = word1[1].split(',')
word2_chars = word2[1].split(',')
word1_class = word1_chars.first
word2_class = word2_chars.first