グローバルイルミネーション

周囲のものから反射する光の影響のこと?

グローバルイルミネーションを再現する方法

レイトレーシング

目から光源までを辿ってゆく
その間にぶつかったもののマテリアルの設定からイルミネーションを再現する?

ラジオシティ

品物同士の角度や面積から明るさを決める
最後に、光強度マップなるものが出来るので、それでレンダリングする?
計算方法としてフォームファクターというのがある

フォトンマッピング

光源から品物までをフォトンで辿る
フォトンは適当な方向に発射される光線?
フォトンは品物にぶつかると消えるか、適当な方向に反射する
最後に、フォトンマップなるものが出来る
その後、レイトレーシングの方法でフォトンマップを使ってレンダリングする

間接フォトンマッピング

間接光源のみフォトンの処理をして、直接光源はグローバルイルミネーションを考慮しない

ファイナルギャザリング

目から品物までを辿ってゆき、ぶつかったところを中心とする半球上の光を集める
光源がなくても品物自体が光る?
直接光源はグローバルイルミネーションを考慮しない
フォトンマップを利用する

パストレーシング

目から光源までを辿ってゆく
反射角度がランダムなレイトレーシング

unicodeのテキストを扱う

python

# -*- coding: sjis -*-
import codecs
f = codecs.open('unicode.txt', 'r', 'utf_16')
for line in f.readlines():
	print line,

perl

use encoding shiftjis;
open FH, "<:encoding(utf-16)", "unicode.txt" or die;
for (<FH>){
	print;
}

jscript

ForReading = 1;
ForWriting = 2;
ForAppending = 8;
TristateUseDefault = -2;
TristateTrue = -1; 
TristateFalse = 0;

fs = new ActiveXObject("Scripting.FileSystemObject");
f = fs.OpenTextFile("unicode.txt", ForReading, 0, TristateTrue);
while (!f.AtEndOfStream) {
	 WScript.Echo(f.ReadLine());
}
a.close();

vbscript

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("unicode.txt", ForReading, False, TristateTrue)
Do While f.AtEndOfStream <> True
  msgbox f.ReadLine
Loop
f.Close

Emacs lispからの簡単移植キットのテスト

http://members.at.infoseek.co.jp/osuneko/xyzzy/xyzzy.html

どこを修正したか

70a71,73
> (in-package "elisp")
> (require "emacs")
> 
90a94,95
> (defvar run-mode-hooks nil)
> 
94,107c99,112
<   (define-key blackbox-mode-map "\C-f" 'bb-right)
<   (define-key blackbox-mode-map [right] 'bb-right)
<   (define-key blackbox-mode-map "\C-b" 'bb-left)
<   (define-key blackbox-mode-map [left] 'bb-left)
<   (define-key blackbox-mode-map "\C-p" 'bb-up)
<   (define-key blackbox-mode-map [up] 'bb-up)
<   (define-key blackbox-mode-map "\C-n" 'bb-down)
<   (define-key blackbox-mode-map [down] 'bb-down)
<   (define-key blackbox-mode-map "\C-e" 'bb-eol)
<   (define-key blackbox-mode-map "\C-a" 'bb-bol)
<   (define-key blackbox-mode-map " " 'bb-romp)
<   (define-key blackbox-mode-map [insert] 'bb-romp)
<   (define-key blackbox-mode-map "\C-m" 'bb-done)
<   (define-key blackbox-mode-map [kp-enter] 'bb-done))
---
>   (define-key blackbox-mode-map #\C-f 'bb-right)
>   (define-key blackbox-mode-map #\Right 'bb-right)
>   (define-key blackbox-mode-map #\C-b 'bb-left)
>   (define-key blackbox-mode-map #\Left 'bb-left)
>   (define-key blackbox-mode-map #\C-p 'bb-up)
>   (define-key blackbox-mode-map #\Up 'bb-up)
>   (define-key blackbox-mode-map #\C-n 'bb-down)
>   (define-key blackbox-mode-map #\Down 'bb-down)
>   (define-key blackbox-mode-map #\C-e 'bb-eol)
>   (define-key blackbox-mode-map #\C-a 'bb-bol)
>   (define-key blackbox-mode-map #\SPC 'bb-romp)
>   (define-key blackbox-mode-map #\Insert 'bb-romp)
>   (define-key blackbox-mode-map #\C-m 'bb-done)
>   (define-key blackbox-mode-map #\RET 'bb-done))
127c132
<   (run-mode-hooks 'blackbox-mode-hook))
---
>   (run-hooks 'blackbox-mode-hook))
246c251
<   (buffer-disable-undo (current-buffer))
---
> ;  (buffer-disable-undo (current-buffer))
257c262,263
<   (random t)
---
>   (setq *random-state* (make-random-state t))
> ;;  (random t)
275c281
<     (insert (format "\nThere are %d balls in the box" (length bb-board)))
---
>     (insert (format nil "\nThere are ~D balls in the box" (length bb-board)))
335c341,343
<       (bb-update-board (propertize "O" 'help-echo "Placed ball"))))))
---
> ;;      (bb-update-board (propertize "O" 'help-echo "Placed ball"))
>       (bb-update-board "O")
> 	  ))))
353c361,362
<         (bb-update-board (propertize "H" 'help-echo "Hit"))
---
> ;;        (bb-update-board (propertize "H" 'help-echo "Hit"))
> 		(bb-update-board "H")
356c365,366
<         (bb-update-board (propertize "R" 'help-echo "Reflection"))
---
> ;;        (bb-update-board (propertize "R" 'help-echo "Reflection"))
> 		(bb-update-board "R")
360,361c370,372
<         (bb-update-board (propertize (format "%d" bb-detour-count)
<                                      'help-echo "Detour"))
---
> ;        (bb-update-board (propertize (format nil "~D" bb-detour-count)
>  ;                                    'help-echo "Detour"))
> 		(bb-update-board (format nil "~D" bb-detour-count))
363,365c374,377
<           (bb-goto result)
<           (bb-update-board (propertize (format "%d" bb-detour-count)
<                                        'help-echo "Detour")))
---
> 		  (bb-goto result)
> ;          (bb-update-board (propertize (format nil "~D" bb-detour-count)
>  ;                                      'help-echo "Detour")))
> 		  (bb-update-board (format nil "~D" bb-detour-count)))
388c400
<       (message "There %s %d hidden ball%s; you have placed %d."
---
>       (message "There ~A ~D hidden ball~A; you have placed ~D."
396,397c408,409
< 	  (message "Right!  Your score is %d." bb-score)
< 	(message "Oops!  You missed %d ball%s.  Your score is %d."
---
> 	  (message "Right!  Your score is ~D." bb-score)
> 	(message "Oops!  You missed ~D ball~A.  Your score is ~D."

uninstallの一覧(vbs)

const HKEY_LOCAL_MACHINE = &H80000002
Set WSHShell = CreateObject("WScript.Shell")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
s = ""
For Each subkey In arrSubKeys
s = s & subkey & vbcrlf
Next
MsgBox s

defaultpasswordの表示(js)

WshShell = WScript.CreateObject ("WScript.Shell");
WScript.Echo (WshShell.RegRead ("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\DefaultPassword"));

JScriptメモ

パラメータを処理する

WScript.Echo("引数は" + WScript.Arguments.length + "個");

for(arguments = new Enumerator( WScript.Arguments ) ; !arguments.atEnd() ; arguments.moveNext() ){
	argument = arguments.item();
	WScript.Echo(argument);
}

Excelの全てのシートを処理する

if (WScript.Arguments.length < 1) {
	WScript.Echo("Excelファイルを指定してください");
	WScript.Quit(1);
}
excel = WScript.CreateObject("Excel.Application");
workBook = excel.WorkBooks.Open(WScript.Arguments(0), 0);

for( sheets = new Enumerator( workBook.WorkSheets ) ; !sheets.atEnd() ; sheets.moveNext() ){
	sheet = sheets.item();
	WScript.Echo(sheet.name);
}

excel.Quit();

テキストをファイルに出力

fso = new ActiveXObject("Scripting.FileSystemObject");
textfile = fso.CreateTextFile(fso.GetParentFolderName(WScript.ScriptFullName)+"\\test.txt", true);
textfile.WriteLine("あああ");
textfile.close();

カレントのファイルを全て処理する

fso = new ActiveXObject("Scripting.FileSystemObject");
folder = fso.GetFolder(".");
for(files = new Enumerator(folder.Files); !files.atEnd(); files.moveNext()) {
	file = files.item();
	WScript.Echo(file);
}

Excelのシートをテキストで保存する

if (WScript.Arguments.length < 1) {
	WScript.Echo("Excelファイルを指定してください");
	WScript.Quit(1);
}
fso = new ActiveXObject("Scripting.FileSystemObject");
excel = WScript.CreateObject("Excel.Application");
workBook = excel.WorkBooks.Open(WScript.Arguments(0), 0);
excel.DisplayAlerts = false;
workBook.saveas(fso.GetParentFolderName(WScript.ScriptFullName)+"\\aaa.txt",  -4158);
excel.Quit();