Skip to content

Instantly share code, notes, and snippets.

View ryoakg's full-sized avatar

℟γồ ᾅḳᐃϼ╿ ryoakg

View GitHub Profile
@ryoakg
ryoakg / tika
Last active May 2, 2016 04:15
command-linized Apache Tika
#! /bin/sh
# http://mvnrepository.com/artifact/org.apache.tika/tika-app
java -jar ~/libexec/tika-app-1.5.jar -t $@
@ryoakg
ryoakg / insert-placeholder-img-tag.lisp
Last active October 18, 2015 01:31
placeholder image tag with lorempixel.com
(defun insert-placeholder-img-tag (gray-p width height category)
"insert placeholder image tag with lorempixel.com"
(interactive
(list current-prefix-arg
(read-number "width: ")
(read-number "height: ")
(completing-read
"category: "
'("animals" "business" "cats" "abstract" "city"
"food" "nightlife" "fashion" "people"
@ryoakg
ryoakg / read-rtf-with-apache-tika.clj
Last active April 20, 2016 14:12
Tikaでrtf読む.文字の色とか大きさは取れなかった.残念
;;; `boot repl` to go
(set-env! :dependencies '[[org.apache.tika/tika-parsers "1.10"]])
(import '(org.apache.tika metadata.Metadata
parser.ParseContext
parser.rtf.RTFParser)
'(java.io StringWriter FileInputStream)
'(javax.xml.transform sax.SAXTransformerFactory
stream.StreamResult
OutputKeys))
@ryoakg
ryoakg / inspect.clj
Last active October 19, 2015 05:42
RTFから文字の色、太字とか装飾情報もとれる。xmlで出力される
(import com.rtfparserkit.parser.standard.StandardRtfParser
com.rtfparserkit.parser.RtfStreamSource
com.rtfparserkit.utils.RtfDump)
(require '[clojure.java.io :as io])
(use 'clojure.pprint)
(def c-counter (atom 0))
(def b-counter (atom 0))
(def s-counter (atom 0))
(def cmd-counter (atom 0))
@ryoakg
ryoakg / browse-current-buffer-file.el
Last active May 23, 2016 12:16
HTMLとか編集しているときに確認する用
(defun browse-current-buffer-file ()
(interactive)
(let ((b (buffer-file-name)))
(if b
(browse-url b)
(message "This buffer is not associated with a file."))))
@ryoakg
ryoakg / nuritsubushi
Last active January 5, 2016 18:22
画像を灰色で塗り潰す
#! /bin/sh
eval `identify -format "convert -size %wx%h xc:gray $1" $1`
@ryoakg
ryoakg / 0_reuse_code.js
Created October 16, 2015 13:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ryoakg
ryoakg / html_element.rb
Last active October 24, 2015 04:08
Nokogiri で要素作成
require 'nokogiri'
#1
elm = Nokogiri::XML::Node.new("meta", Nokogiri::HTML::DocumentFragment.parse(""))
elm['http-equiv'] = "Content-Type"
elm['content'] = "text/html; charset=UTF-8"
puts elm.to_s
#2
elm = Nokogiri::HTML::DocumentFragment.parse('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">').children[0]
@ryoakg
ryoakg / html_charset.rb
Last active October 24, 2015 04:07
Nokogiri で head > meta に書いてある文字コードの確認
require 'nokogiri'
open('xxx.html') {|f|
doc = Nokogiri::HTML(f)
puts doc.css('head > meta[http-equiv="Content-Type"]')[0]['content']
}
@ryoakg
ryoakg / clear_script_tag.rb
Last active October 24, 2015 04:04
script, noscript を全部抜く
require 'nokogiri'
open('xxx.html') {|f|
doc = Nokogiri::HTML(f)
doc.css('script, noscript').each(&:unlink)
open(output_filename, mode='w'){|f|
html_str = doc.to_html(encoding: 'UTF-8')
f.print html_str
}
}