Skip to content

Instantly share code, notes, and snippets.

@ser1zw
ser1zw / match_template_sample.rb
Created April 20, 2012 15:12
ruby-opencvのテンプレートマッチングのサンプル
# ruby-opencvのテンプレートマッチングのサンプル
# https://github.com/ruby-opencv/ruby-opencv
require 'opencv'
include OpenCV
# (1) 画像を読み込み
image = CvMat.load('image.jpg') # テンプレートと比較する画像
template = CvMat.load('template.jpg') # テンプレート画像
@ser1zw
ser1zw / benchmark.rb
Created April 26, 2012 15:27
win32screenshotで撮ったスクリーンショットをruby-opencvのCvMatに読み込む方法のベンチマーク
# win32screenshotで撮ったスクリーンショットをruby-opencvのCvMatに読み込む方法のベンチマーク
#
# 環境: Windows 7, Core i5 2.4GHz, メモリ 4.0GB, ディスプレイ解像度 1280x800px
# ruby 1.9.3p125 (2012-02-16) [i386-mingw32], OpenCV 2.3.1
#
# > ruby benchmark.rb
# (1) Bitmapデータを配列にしてset_dataで読み込む版
# user system total real
# 1.934000 0.062000 1.996000 ( 2.061118)
#
@ser1zw
ser1zw / win32screenshot2ruby-opencv.rb
Created April 26, 2012 15:28
win32screenshotで撮ったスクリーンショットをruby-opencvのCvMatに読み込むサンプル
# win32screenshotで撮ったスクリーンショットをruby-opencvのCvMatに読み込むサンプル
require 'opencv'
require 'win32/screenshot'
require 'tempfile'
include OpenCV
# (1) スクリーンショットを撮る
screenshot = Win32::Screenshot::Take.of(:desktop)
# (2) スクリーンショットの画像データを一時ファイルに書き込んでからCvMat.loadで読み込む
@ser1zw
ser1zw / exec-sqlplus.l
Created June 7, 2012 15:51
カレントバッファの内容をSQL*Plusで実行するxyzzy lisp
;; カレントバッファの内容をSQL*Plusで実行
(defun exec-sqlplus ()
(interactive)
(let ((user "SCOTT")
(passwd "TIGER")
(host "localhost")
(port 1521)
(service-name "XE")
(filename (make-temp-file-name))
command
@ser1zw
ser1zw / COUNT_ALL_TABLES.SQL
Created June 22, 2012 20:42
SQL for counting rows of all tables (tested on Oracle 10g)
-- SQL for counting rows of all tables (tested on Oracle 10g)
-- http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html
SELECT
TABLE_NAME,
TO_NUMBER(
EXTRACTVALUE(
XMLTYPE(DBMS_XMLGEN.GETXML('SELECT COUNT(*) C FROM ' || TABLE_NAME)),
'/ROWSET/ROW/C'
)
) COUNT
@ser1zw
ser1zw / approx_poly_sample.rb
Created August 19, 2012 03:55
ruby-opencvのCvContour#approx_polyのサンプル
require 'opencv'
include OpenCV
# (1)画像を読み込んで2値化
img = CvMat.load('lenna.png') # ※適当な画像を指定してください
gray = img.BGR2GRAY
bin = gray.threshold(100, 255, :binary)
# (2)近似対象の輪郭線を取得
contours = bin.find_contours(:mode => CV_RETR_EXTERNAL)
@ser1zw
ser1zw / PLSQL_WWW_GET_SAMPLE.sql
Created September 20, 2012 19:03
PL/SQL sample for HTTP access
/*
PL/SQL sample for HTTP access (Oracle 11g R2)
1. Execute /u01/app/oracle/product/11.2.0/xe/rdbms/admin/utlhttp.sql to use UTL_HTTP package
Run the following command in shell in the DB server
$ cd /u01/app/oracle/product/11.2.0/xe/rdbms/admin/
$ sqlplus SYS/passwd@localhost:1521/XE AS SYSDBA @utlhttp.sql
2. Grant the connect and resolve privileges for all hosts to the user 'SCOTT'
Run the following commands in SQL*Plus
@ser1zw
ser1zw / HtmlParseSample.java
Created December 7, 2012 19:14
JavaでHTMLからテキストを取得するサンプル
package sample;
import javax.swing.text.html.parser.ParserDelegator;
import java.io.StringReader;
/**
* JavaでHTMLからテキストを取得するサンプル
*
* @see http://docs.oracle.com/javase/jp/6/api/javax/swing/text/html/parser/ParserDelegator.html
* @see http://docs.oracle.com/javase/jp/6/api/javax/swing/text/html/HTMLEditorKit.ParserCallback.html
@ser1zw
ser1zw / send.ps1
Created December 23, 2012 21:59
Send E-mail from eml file in PowerShell
################################################################################
# Send E-mail from eml file in PowerShell
# Tested on PowerShell 2.0
#
# Usage:
# 1. Configure the variables defined in Main()
# $server = "localhost"
# $port = "25"
# $mailfrom = "from@example.com"
# $rcptto = "to@example.com"
@ser1zw
ser1zw / send-message.py
Last active January 17, 2018 18:09
Send E-mail from eml file in Python
#!/usr/bin/env python
# -*- mode: python; coding: utf-8 -*-
import sys
import os.path
import smtplib
if len(sys.argv) <= 2:
print('Usage:')
print(' $ python ' + sys.argv[0] + ' mailfrom rcptto <emlfile>')
print('')