Skip to content

Instantly share code, notes, and snippets.

View smallmake's full-sized avatar

Eiji Nakai smallmake

View GitHub Profile
@smallmake
smallmake / bootstrap_popover_example.js
Last active August 29, 2015 14:20
JQuery: Bootstrap popover のcontent htmlの手動セットとcloseボタン設置
# samenames_html is html to display in popover
if (samenames_html.length > 0) {
$("#popoverSameNames").popover({
title: '同姓同名があります.<span class="close">&times;</span>',
template: '<div class="popover" role="tooltip" style="width:500px;font-size:80%;"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"><div class="data-content"></div></div></div>',
html: true
}).on('shown.bs.popover', function(e){
var popover = $(this);
$(this).parent().find('div.popover .close').on('click', function(e){
popover.popover('hide');
@smallmake
smallmake / drawWithRect_tail_truncation.swift
Last active August 29, 2015 14:22
drawWithRectでTail Truncationする(ParagraphではなくRectで)
let style = NSMutableParagraphStyle()
style.lineBreakMode =.ByWordWrapping
style.alignment = NSTextAlignment.Left
let stringAttrubute = [
NSParagraphStyleAttributeName: style
]
let sampleText = "このStringは、このように...(略)...するようにしたい。途中で改行がはいるのである。\nどうすればいいのだろう?あ、できた!\nそして、まだまだStringは続く....(略)...."
sampleText.drawWithRect(
CGRectMake(0,0,800,300),
options: .UsesLineFragmentOrigin | .TruncatesLastVisibleLine,
require 'icalendar'
require 'csv'
require 'optparse'
option={}
OptionParser.new do |opt|
opt.on('-f', '--file=VALUE', 'iCal(ics) file path') {|v| option[:ics_file] = v}
opt.on('-a', '--after=VALUE','after when: YYYY/mm/dd eg: -a 2015/11/22') {|v| option[:after_when] = v}
opt.parse!(ARGV)
end
require "nokogiri"
doc = Nokogiri::HTML(File.open("appearance_jp.html"))
doc.xpath('//form').first.xpath('.//input','.//select','.//textarea').each do |e|
puts "#{e.name}, type:#{e['type']}, name:#{e['name']}, class:#{e['class']}"
end
@smallmake
smallmake / ndl_search_sample.rb
Last active June 5, 2021 15:30
国会図書館検索API利用サンプル
require "faraday"
require 'nokogiri'
class NdlSearch
def get_book_info(title, creator = nil)
data = []
query = {
:mediatype => 1,
:cnt => 10
@smallmake
smallmake / nhkkw.rb
Last active June 13, 2019 03:06
NHKの番組情報APIを使って番組情報を取得しキーワードで検索して通知します
#! /usr/bin/env ruby
require "faraday"
require "json"
require "time"
require "csv"
require "mail"
require "active_support/all"
NHK_API_KEY = ENV['NHK_API_KEY']