Skip to content

Instantly share code, notes, and snippets.

@ser1zw
ser1zw / QuickSort.cs
Created July 5, 2013 19:10
C#でクイックソートの練習
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)
{
@ser1zw
ser1zw / quicksort.lisp
Created July 5, 2013 17:51
Common Lispでクイックソートの練習
;; -*- 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)
@ser1zw
ser1zw / quicksort.c
Created July 5, 2013 17:48
C言語でクイックソートの練習
// -*- 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;
}
;; -*- 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)))))
@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('')
@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 / 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 / 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 / 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 / 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