Skip to content

Instantly share code, notes, and snippets.

@kencoba
kencoba / ReadDataFromWorkbookWithPasswd.vba
Created January 13, 2020 04:12
Open workbooks in the "path" with "passwd", and read data.
Public Sub パスワード付きファイルを開く()
Dim path As String
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = True Then
path = .SelectedItems(1)
End If
End With
Dim passwd As String
passwd = InputBox("読み取りパスワード", "読み取りパスワード", "")
@kencoba
kencoba / MultiRowsIntoOne.vb
Created December 6, 2019 02:44
ExcelVBA:Transform data from multible rows into one.
Option Explicit
Public Sub 複数行を単一行へ変換()
Dim 入力シート As Worksheet
Dim 出力シート As Worksheet
Dim 入力行 As Integer ' 入力シートのキーの行番号
Dim 入力列 As Integer ' 入力シートの値の列番号
Dim 出力行 As Integer ' 出力シートの出力行番号
Dim 出力列 As Integer ' 出力シートの出力列番号
Dim 値列数 As Integer ' 値の列数
@kencoba
kencoba / tt.py
Created April 3, 2019 05:42
Touch Typing with Python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
import random
def interval():
start_time = time.time()
def end_time():
return time.time() - start_time
return end_time
@kencoba
kencoba / tt.rb
Created April 2, 2019 08:47
Touch Typing with Ruby
# tt.rb
def interval ()
start_time = (Time.now.to_f * 1000).to_i
lambda {
end_time = (Time.now.to_f * 1000).to_i
end_time - start_time
}
end
@kencoba
kencoba / Prototype.scala
Created February 21, 2012 07:46
Prototype pattern (Design Patterns in Scala)
@cloneable
class Command(value: Int, name: String) {
override def clone = super.clone
override def toString = value + ": " + name
}
object Main {
def main(args: Array[String]) = {
val com1 = new Command(1, "Hoge")
val com2 = com1.clone
@kencoba
kencoba / Adapter.scala
Created February 21, 2012 10:51
Adapter pattern (Design Patterns in Scala)
trait ProductPrice {
def price: Int
}
class Product {
var cost = 500
}
class ProductDelegationAdapter extends ProductPrice {
private var product = new Product
@kencoba
kencoba / FactoryMethod.scala
Created February 21, 2012 06:04
FactoryMethod pattern (Design Patterns in Scala)
// http://blog.designrecipe.jp/2011/01/03/factory-method-strategy/
abstract class ListPrinter {
def printList(list: List[String]) {
val comparator = createComparator
list.sortWith(comparator).foreach(println)
}
protected def createComparator: (String, String) => Boolean
}
@kencoba
kencoba / magic-hexagram.scm
Created July 30, 2017 12:01
Magic hexagram
(use util.combinations)
(use gauche.collection)
; Magic hexagram
;
; a
; / \
; b---c---d---e
; \ / \ /
; f g
@kencoba
kencoba / Points.ps1
Created May 15, 2017 05:50
This is for control PowerPoint with PowerShell.
Class Points {
[double] $Left
[double] $Top
[double] $Width
[double] $Height
[Points] Magnify([double] $percent) {
$center_X = $this.Left + ($this.Width / 2)
$center_Y = $this.Top + ($this.Height /2)
$newWidth = $this.Width * $percent
@kencoba
kencoba / diffs.sh
Last active July 11, 2017 02:04
compute diffs for each png files in the directory.
#!/usr/bin/env zsh
if [ $# -ne 2 ]; then
echo "$# args specified" 1>&2
echo "usage: sh ./diffs.sh marker_filename target_directory" 1>&2
exit 1
fi
for target in $2/*.png
do