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
using System; | |
namespace QuickSort | |
{ | |
class MainClass | |
{ | |
private static void quickSortInternal<Type>(Type[] array, int left, int right, Func<Type, Type, int> compare) | |
{ | |
if (left >= right) | |
{ |
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
;; -*- mode: lisp; coding: utf-8 -*- | |
(defun quick-sort(lst &optional (test-func #'<)) | |
(if (<= (length lst) 1) | |
lst | |
(let (upper | |
lower | |
(pivot (car lst))) | |
(dolist (v (cdr lst)) | |
(if (funcall test-func v pivot) |
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
// -*- mode: c; coding: utf-8 -*- | |
#include <stdio.h> | |
void quicksort_internal(int array[], int left, int right, int (*test_func)(int, int)) { | |
int pivot; | |
int i, j, tmp; | |
if (left >= right) { | |
return; | |
} |
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
;; -*- mode: lisp-interaction -*- | |
;; http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html | |
;; P01 | |
(defun my-last (lst) | |
(if (null lst) | |
nil | |
(if (null (cdr lst)) | |
lst | |
(my-last (cdr lst))))) |
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('') |
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
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
/* | |
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
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
-- 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 |