This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby-opencvのテンプレートマッチングのサンプル | |
# https://github.com/ruby-opencv/ruby-opencv | |
require 'opencv' | |
include OpenCV | |
# (1) 画像を読み込み | |
image = CvMat.load('image.jpg') # テンプレートと比較する画像 | |
template = CvMat.load('template.jpg') # テンプレート画像 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# win32screenshotで撮ったスクリーンショットをruby-opencvのCvMatに読み込むサンプル | |
require 'opencv' | |
require 'win32/screenshot' | |
require 'tempfile' | |
include OpenCV | |
# (1) スクリーンショットを撮る | |
screenshot = Win32::Screenshot::Take.of(:desktop) | |
# (2) スクリーンショットの画像データを一時ファイルに書き込んでからCvMat.loadで読み込む |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; カレントバッファの内容をSQL*Plusで実行 | |
(defun exec-sqlplus () | |
(interactive) | |
(let ((user "SCOTT") | |
(passwd "TIGER") | |
(host "localhost") | |
(port 1521) | |
(service-name "XE") | |
(filename (make-temp-file-name)) | |
command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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('') |