Open Source WEB

そのとき使ったコマンド、設定、チョットしたプログラミングのTipsなどを書きためておきます。(もちろん無保証です)


索引

  • 索引を試作してみました。どうかなぁ。 --初心者

※ このページはkaretta.jpの今日の一行をミラーしています。


2010-04-02 Ubuntuでデフォルトエディタとしてnanoが起動してしまうことを回避する

システム設定とユーザ設定でnanoが起動することを抑止するにはいろいろ方法があるが、以下がとても有効である。

 sudo apt-get remove nano


2010-02-15 KNOPPIXでWindowsのパスワードをリセットする

用意するもの:

  • USBメモリ
  • KNOPPIX 6.0 CD

手順:

  1. Ubuntu等のLinuxでUSBメモリをマウントし、以下を行う。ここではUSBメモリのパスを/media/usbdiskとする
    sudo apt-get install chntpw
    cp /usr/sbin/chntpw /media/usbdisk
    
  2. WindowsマシンをKNOPPIX CDで起動し、1のUSBメモリを挿して以下を行う。ここではWindowsがインストールされたHDDを/dev/hda1とする。SAMファイルの位置はWindowsのバージョンによって異なる
    sudo mount -o rw /dev/hda1 /media/hda1
    /media/usbdisk/chntpw /media/hda1/Windows/System32/config/SAM
    

参考文献: http://rhadimas.wordpress.com/2006/10/15/reset-windows-password-w-knoppix/



2009-06-12 Mac OS X 10.5でbinユーザーを作成する

Mac OS Xでgdbmをビルドしてインストールするとエラー。

/usr/bin/install -c -m 644 -o bin -g bin gdbm.h \
                /usr/local/include/gdbm.h
install: bin: Invalid argument
make: *** [install] Error 67

これはbinというユーザーが存在しないため。

Mac OS X 10.5 (Leopard)ではこうする。

sudo dscl . create /Groups/bin
sudo dscl . create /Users/bin


2009-05-21 wgetでファイル名と同じディレクトリ名が存在するときの対処法

たとえば http://www.lingr.com/room/gauche/achives 配下をローカル保存したいなら以下とする。

 wget -m -np -x http://www.lingr.com/room/gauche/achives/

ポイントはURL末尾に/を付けること。

wgetは、

  1. パス名の末尾に/をつけないとファイルとみなしてarchivesという名前のファイルが出来る
  2. パス名の末尾に/をつけるとディレクトリだとみなしてachives配下にindex.htmlという名前のファイルが出来る

という挙動のようである。

wgetの-xオプションはディレクトリを強制作成する。



2009-03-22 日本語版Windows XPでPC101配列またはDvorak配列を使う

PC101配列を使いたい場合:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters]
"PollingIterations"=dword:00002ee0
"PollingIterationsMaximum"=dword:00002ee0
"ResendIterations"=dword:00000003
"LayerDriver JPN"="KBD101.dll"
"LayerDriver KOR"="KBD101A.DLL"
"OverrideKeyboardType"=dword:00000007
"OverrideKeyboardSubtype"=dword:00000000
"OverrideKeyboardIdentifier"="PCAT_101KEY"

Dvorak配列を使いたい場合:

"LayerDriver JPN"="kbddv.dll"



過去の「今日の一行」



今月の一行


2006-10-19 [Haskell] トドちゃんカウンタ

結城さんのトドちゃんを数えるPerlスクリプトのHaskell版

カレントディレクトリにある *.txt ファイル中の行頭が todo: であるような行の数を数えて,ファイル毎の todo の数と,トータルを表示する.

% countTodo.lhs
2006-10-15.txt: 3
2006-10-16.txt: 12
2006-10-17.txt: 8
2006-10-18.txt: 20
ε(     v ゜ω゜) < TODO 43 頭♪

てな感じ.

#!/usr/bin/env runhaskell
\begin{code}
module Main (main) where

import Control.Monad (foldM)
import Data.Char (toLower)
import Data.List (isPrefixOf,isSuffixOf)
import System.Directory (getCurrentDirectory,getDirectoryContents)

import UTF8        -- 俺様UTF8.hs

main :: IO ()
main =   getCurrentDirectory 
     >>= getDirectoryContents
     >>= foldM countTodo 0 . filter (".txt" `isSuffixOf`)
     >>= putStrLn . toUTF8 . todo

todo :: Int -> String
todo c = "ε(     v ゜ω゜) < TODO "++show c++" 頭♪"

countTodo :: Int -> String -> IO Int
countTodo c f
 = flip catch 
        (return . const c)
        (do { cs <- readFile f
            ; let len = length  $ filter (("todo:" `isPrefixOf`).map toLower)
                                $ lines cs
            ; putStrLn $ ((f ++ ": ")++) $ show len
            ; return (c+len)
            })
\end{code}

--nobsun


Name:
Comment:
EyeUbLoOFtbZQv: (Tue Dec 30 08:46:34 2008 )
BgSdcN
googlaaa: (Thu Apr 23 19:17:52 2009 )
UC8w9Z http://google.com
SjQxpSiTA: (Tue Sep 15 20:23:39 2009 )
doors.txt;10;15
cjdwDLHakPZKQ: (Sun Oct 11 23:09:05 2009 )
awegaw1.txt;2;5
Faggot56: (Fri Oct 23 02:28:04 2009 )
The basic purpose, scope and principles of the document remain  unchanged. ,
sandy: (Sun May 30 02:58:43 2010 )
jlIISi http://f8j3ndYbs83Bbq06Wlavp.com
samanta: (Wed Sep 1 11:20:16 2010 )
icQZRo http://djb3jDdmjckow30cnjcmd61l0dy.com
canadian drugs onlin: (Thu Feb 17 17:58:25 2011 )
Very nice post, good luck! ;-)
jonn1: (Tue Jul 19 02:19:30 2011 )
comment1,
jonn1: (Tue Jul 19 02:41:20 2011 )
comment4,
crysty: (Sun Jul 31 09:10:47 2011 )
d3HvYo http://ueNx8wqkk3Mnd.com
marmont: (Sun Jul 31 13:38:15 2011 )
63UMlU http://dcYhnkl3mg78Nsfi.com
trinity: (Sun Jul 31 14:02:54 2011 )
2mvoNC http://www.tdHn2o99genVcoe.net
geoge: (Sun Jul 31 16:20:37 2011 )
gT5K74 http://www.nYwl9n4vb4BsdL2kt.net
marmont: (Tue Aug 23 06:03:37 2011 )
9kv1FC http://dfb6WkPnj4bYud6v2Oxt.com
trinity: (Tue Aug 23 18:27:32 2011 )
rIAWUj http://cbTqto62bOpdn54BcCqp.net
trinity: (Wed Aug 24 07:24:42 2011 )
GCXG3X http://www.ErjfoeBnen03bY1mB7bz.com
joseph: (Wed Aug 24 20:05:01 2011 )
6R4jx1 http://wnbUj5n0mXqpcvm27Hms.biz
b0SamueL0b: (Sat Sep 10 07:44:20 2011 )
+z$8frZdyL%68pSU/:>w<:E3.lG-!XIB
Aeoxxomr: (Sun Sep 11 21:55:52 2011 )
Where are you calling from?
uiTomas0k: (Fri Sep 16 00:00:51 2011 )
http://BPsU(-Zv8B&/LCOJtd6WZB!+%v!H(&v9.com
geogen: (Tue Oct 4 21:59:45 2011 )
47lxuS http://6u0n0h0g4gUJK0UP.com
trinity: (Wed Oct 5 14:53:35 2011 )
kmXs5L http://DUIyaPoAghaOOv2A.net
joseph: (Thu Oct 6 07:42:33 2011 )
AJy09O http://aAQKOiop2iLyMpBz.biz
Wilman: (Thu Oct 6 14:13:55 2011 )
n59EkK http://CA6HyasJOMgLwTQE.net
vwvzksmoij: (Fri Oct 21 22:20:37 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
Wilman: (Fri Oct 28 23:25:31 2011 )
BH1x6x http://M8bJXXT7yzZFp1CH.com
gcmcieqgdb: (Sun Nov 27 11:54:21 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:14:38 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf
DrZoibergLo: (Tue Nov 29 18:27:04 2011 )
http://www.QKiMt6vfLbn1bD0zxU9QchzPHO25ZYPy.com
joseph: (Tue Jan 3 09:14:17 2012 )
http://www.l4kQDD30zNsyoG7pFkTOj6m6mXdUqdwF.com
trinity: (Tue Jan 3 10:18:26 2012 )
http://www.NIzi0QxjqKwVZYJ0oEPJhqfCBoLXzubW.com
pHLMEZJ7: (Wed Jan 25 00:10:05 2012 )
2vunns http://www.RUWE5gOde94HqsfDYIh3uBfJfSMdiDSG.com
Oalwgqpu: (Thu Jan 26 05:40:15 2012 )
Photography


2006-10-18 [MySQL] MySQL 4.0のmysqldumpで出力されたEUC-JPのデータを5.0にレストア

MySQL 4.0でEUC-JPを格納したデータベースをmysqldumpで出力していたとする。

そのままMySQL 5.0にレストアすると文字化けすることがある。

これを回避するには、/etc/my.cnfに以下を追加してMySQLサーバーを再起動し、レストアする。

[mysqld]
default-character-set = ujis
old-passwords

# 5.0.13-rc 以上
skip-character-set-client-handshake

[mysqldump]
default-character-set = ujis
skip-opt

[mysql]
default-character-set = ujis

参考文献: http://www.mysql.gr.jp/frame/modules/bwiki/?FAQ#content_1_48

なお、Mac OS X等で/etc/my.cnfが存在しないときは新たに作成する。

再起動後のレストアは以下。

mysql -u username dbname < mysqldumpfile.sql

--yasuyuki


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:20:51 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:54:26 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:14:42 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-17 [Haskell] GHC 6.6 released

Glasgow Haskell Compiler, Version 6.6 が 10/11 にリリースされました.

リリースノートを見ると.

  • GHC now treats source files as UTF-8 (ASCII is a strict subset of UTF-8, so ASCII source files will continue to work as before). However, invalid UTF-8 sequences are ignored in comments, so ASCII code with comments in, for example, Latin-1 will also work.

などとある.

main = putStrLn "日本語"

を utf-8 で保存して(utf.hs),utf-8の端末で,

% runhaskell utf.hs

とやると化け化け.どうやら,getContents と putStr とかでは UTF-8 <-> UNICODE を やってくれるわけじゃないらしい.というわけででっち上げた UTF8.hs

module UTF8(toUTF8, fromUTF8) where

import Data.Bits
import Data.Char
import Data.Word(Word8)

-- Convert Unicode character to UTF-8.

toUTF8 :: String -> String
toUTF8 [] = []
toUTF8 (x:xs) | ch<=0x007F    = x : toUTF8 xs
              | ch<=0x07FF    = chr (0xC0 .|. ((ch `shift`  (-6)) .&. 0x1F))
                              : chr (0x80 .|. (ch .&. 0x3F))
                              : toUTF8 xs
              | otherwise     = chr (0xE0 .|. ((ch `shift` (-12)) .&. 0x0F))
                              : chr (0x80 .|. ((ch `shift`  (-6)) .&. 0x3F))
                              : chr (0x80 .|. (ch .&. 0x3F))
                              : toUTF8 xs
  where ch = ord x

-- Convert UTF-8 to Unicode.

fromUTF8 :: String -> String
fromUTF8 []     = []
fromUTF8 xxs@(x:xs)
    | ch<=0x7F  = x : fromUTF8 xs
    | ch< 0xC0  = err
    | ch<=0xDF  = f2 xs
    | ch< 0xE0  = err
    | ch<=0xEF  = f3 xs
    | otherwise = err'
    where ch = ord x
          f2 (y0:ys)    = chr (((ch .&. 0x1F) `shift`  6) .|. (ord y0 .&. 0x3F))
                        : fromUTF8 ys
          f2 _          = error "fromUTF8: illegal two byte sequence"
          f3 (y0:y1:ys) = chr (((ch .&. 0x0F) `shift` 12) .|. ((ord y0 .&. 0x3F) `shift` 6)
                                                          .|. (ord y1 .&. 0x3F))
                        : fromUTF8 ys
          f3 _          = error "fromUTF8: illegal three byte sequence"
          err           = error "fromUTF8: illegal UTF-8 character"
          err'          = error "fromUTF8: not support UTF-8 in more than 3 byte"

フル対応ではない,ええかげんなもの.先刻のを

import UTF8
main = putStrLn $ toUTF8 "日本語"

とすると

% runhaskell utf8.hs                                                  ~
日本語

パチパチ

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:21:04 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:54:34 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:14:45 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-16 [Haskell] XOR 難読化

Puzzle for Hackers: スクリプトキディから大人のハッカーへという本に登場するツール.

% bvi sample.txt
00000000  63 72 65 61 74 75 72 65 5F 63 72 65 61 74 75 72 creature_creatur
00000010  65 5F 63 72 65 61 74 75 72 65                   e_creature
% xorer < sample.txt > sample.enc
% bvi sample.enc
00000000  5D 56 54 59 4A 51 43 5D 61 47 43 5D 5F 50 44 4A ]VTYJQC]aGC]_PDJ
00000010  5B 7B 52 4A 5B 45 45 4D 4C 41                   [{RJ[EEMLA
% xorer < sample.enc
creature_creature_creature

Haskell で書いてみた.

#!/usr/bin/env runhaskell
\begin{code}
module Main (main) where

import Data.Bits (xor)
import Data.Char (ord, chr)
import System.Environment (getArgs, getProgName)
import System.IO (hPutStr,stderr)

type Key = String

starling :: (a -> b -> c) -> (a -> b) -> a -> c
starling f g x = f x (g x)

enc :: Key -> String -> String
enc = zipWith e . cycle  
  where e k c = chr (ord k `xor` ord c)

-- test data

key = ">$18"
plain = "creature_creature_creature"
enced = "]VTYJQC]aGC]_PDJ[{RJ[EEMLA"

-- main

main :: IO ()
main = do { prog  <- getProgName
          ; args  <- getArgs
          ; cs    <- getContents
          ; case args of
              []  -> putStr $ enc key cs
              [k] -> putStr $ enc k cs
              _   -> usage prog
          }

usage :: String -> IO ()
usage prog = hPutStr stderr ("Usage: "++prog++" [key] < file")
              
\end{code}

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:21:15 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:54:43 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:14:49 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-13 [Haskell] infix2rpn

2006-10-06のHaskellによる実装.infix2rpn.lhs

  • 字句解析はちょいとだけ書く lexing
  • 構文解析も素朴に書く infix2tree
  • プリティプリンタは,2006-10-11のものそのまま.
#!/usr/bin/env runhaskell
\begin{code}
module Main (main) where

import Data.Char (isDigit,isSpace)
import Data.Tree (Tree(..))
import System.Environment (getArgs, getProgName)
import System.IO (hPutStrLn, stderr, stdout)

usage :: String -> String
usage prog = "Usage: "++prog++" \"<infix expression>\""

main :: IO ()
main = do { prog <- getProgName
          ; args <- getArgs
          ; case args of
              [e] -> hPutStrLn stdout $ ppr $ infix2tree $ lexing e
              _   -> hPutStrLn stderr $ usage prog
              
          }

lexing :: String -> [String]
lexing = lx []
  where lx ls [] = reverse ls
        lx ls (c:cs) | isSpace c       = lx ls cs
                     | elem c "()+-*/" = lx ([c]:ls) cs
                     | isDigit c       = case span isDigit cs of
                                           (xs,ys) -> lx ((c:xs):ls) ys
                     | otherwise       = error "Invalid Lexeme"

infix2tree :: [String] -> Tree String
infix2tree = r2t 0 []
  where r2t 0 [t] []   = t
        r2t 0 _   []   = error "Invalid Infix Expression"
        r2t n ts  (x:xs)
           | x == "("  = r2t (n+1) ts xs
           | x == ")"  = case ts of
                          (r:o:l:ts') -> r2t (n-1) (Node (node o) [l,r]:ts') xs
                          _           -> error "Invalid Infix Expression"
           | all isDigit x = r2t n (Node x [] : ts) xs
           | elem x ["+","-","*","/"]
                       = r2t n (Node x []:ts) xs
           | otherwise = error "Invalid Infix Expression"
        node (Node x _) = x

ppr :: Tree String -> String
ppr = unwords . post

post :: Tree String -> [String]
post (Node x cs) = concatMap post cs ++ [x]
\end{code}

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:21:26 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:54:46 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:14:53 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-12 [Haskell] rpn2infix

2006-10-05のHaskellによる実装.rpn2infix.lhs

  • 字句解析,構文解析は2006-10-10の rpn2pn.lhs そのまま.
  • プリティプリンタは括弧を付ける.
#!/usr/bin/env runhaskell
\begin{code}
module Main (main) where

import Data.Char (isDigit)
import Data.Tree (Tree(..))
import System.Environment (getArgs, getProgName)
import System.IO (hPutStrLn, stderr, stdout)

usage :: String -> String
usage prog = "Usage: "++prog++" \"<rpn expression>\""

main :: IO ()
main = do { prog <- getProgName
          ; args <- getArgs
          ; case args of
              [e] -> hPutStrLn stdout $ ppr $ rpn2tree $ words e
              _   -> hPutStrLn stderr $ usage prog
              
          }

rpn2tree :: [String] -> Tree String
rpn2tree = r2t []
  where r2t [t] [] = t
        r2t _   [] = error "Invalid RPN Expression"
        r2t ts  (x:xs)
           | all isDigit x = r2t (Node x []:ts) xs
           | otherwise     = case ts of
                               (r:l:rs) -> r2t (Node x [l,r]:rs) xs
                               _        -> error "Invalid RPN Expression"

ppr :: Tree String -> String
ppr (Node x [])    = x
ppr (Node x [l,r]) = "("++ppr l++" "++x++" "++ppr r++")"
\end{code}

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:23:46 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
vwvzksmoij: (Fri Oct 21 22:24:33 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:54:56 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:14:55 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-11 [Haskell] pn2rpn

2006-10-04のHaskellによる実装.pn2rpn.lhs

  • 字句解析は2006-10-10と同様,手抜き
  • 構文解析はちょっとだけ工夫
  • プリティプリンタは計算木をpost-orderでたどって,文字列を集めて unwords
#!/usr/bin/env runhaskell
\begin{code}
module Main (main) where

import Data.Char (isDigit)
import Data.Tree (Tree(..))
import System.Environment (getArgs, getProgName)
import System.IO (hPutStrLn, stderr, stdout)

usage :: String -> String
usage prog = "Usage: "++prog++" \"<rpn expression>\""

main :: IO ()
main = do { prog <- getProgName
          ; args <- getArgs
          ; case args of
              [e] -> hPutStrLn stdout $ ppr $ pn2tree $ words e
              _   -> hPutStrLn stderr $ usage prog
          }

pn2tree :: [String] -> Tree String
pn2tree = maybe (error "Invalid PN Expression") fst . p2t
  where p2t [] = Nothing
        p2t (x:xs) | all isDigit x = Just (Node x [], xs)
                   | otherwise = do { (l, xs')  <- p2t xs
                                    ; (r, xs'') <- p2t xs'
                                    ; return (Node x [l,r], xs'')
                                    }
ppr :: Tree String -> String
ppr = unwords . post

post :: Tree String -> [String]
post (Node x cs) = concatMap post cs ++ [x]
\end{code}

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:24:53 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:55:02 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:14:59 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-10 [Haskell] rpn2pn

2006-10-03のHaskellによる実装.rpn2pn.lhs

この類いは,

  1. 字句解析で文字列から字句列へ変換
  2. 構文解析で字句列から計算木へ変換
  3. プリティプリンタで計算木から文字列へ変換

というのが考えやすい.

  • 字句解析は手抜き,wordsを使っている.つまり,入力文字列中ではオペレータとオペランドは空白で区切られていることを前提としている.
  • 構文解析はRPNだけあってStackを使うだけ.
  • プリティプリンタは構文木をpre-orderで辿って文字列を集めて,unwords するだけ.
#!/usr/bin/env runhaskell
\begin{code}
module Main (main) where

import Data.Char (isDigit)
import Data.Tree (Tree(..))
import System.Environment (getArgs, getProgName)
import System.IO (hPutStrLn, stderr, stdout)

usage :: String -> String
usage prog = "Usage: "++prog++" \"<rpn expression>\""

main :: IO ()
main = do { prog <- getProgName
          ; args <- getArgs
          ; case args of
              [e] -> hPutStrLn stdout $ ppr $ rpn2tree $ words e
              _   -> hPutStrLn stderr $ usage prog
              
          }

rpn2tree :: [String] -> Tree String
rpn2tree = r2t []
  where r2t [t] [] = t
        r2t _   [] = error "Invalid RPN Expression"
        r2t ts  (x:xs)
           | all isDigit x = r2t (Node x []:ts) xs
           | otherwise     = case ts of
                               (r:l:rs) -> r2t (Node x [l,r]:rs) xs
                               _        -> error "Invalid RPN Expression"

ppr :: Tree String -> String
ppr = unwords . pre

pre :: Tree String -> [String]
pre (Node x cs) = x : concatMap pre cs

\end{code}

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:25:05 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
vwvzksmoij: (Fri Oct 21 22:25:53 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:55:06 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:15:03 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-06 [quiz] 中置の四則演算表記を逆ポーランド記法表記に変換する

2006-10-05の逆.括弧が都合よくはいっていると仮定してよい.

これもお約束.

% infix2rpn "(((1 / 9) + 1) * 9)"
1 9 / 1 + 9 *

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:25:57 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:55:12 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:15:06 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-05 [quiz] 逆ポーランド記法の四則演算表記を中置記法に変換する

逆ポーランド記法の四則演算表記を中置記法表記に変換するツールをrpn2infixを作れ.

お約束ですねぇ.

% rpn2infix "1 9 / 1 + 9 *"
(((1 / 9) + 1) * 9)

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:26:02 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:55:17 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:15:10 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-04 [quiz] ポーランド記法の四則演算表記を逆ポーランド記法表記に変換する

2006-10-03の逆のツール ポーランド記法の四則演算を表記を逆ポーランド記法表記に変換するツールを pn2rpnを作れ.

% pn2rpn "* + / 1 9 1 9"
1 9 / 1 + 9 *

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:26:08 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:55:23 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:15:14 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-03 [quiz] 逆ポーランド記法の四則演算表記をポーランド記法表記に変換する

逆ポーランド記法の四則演算を表記をポーランド記法表記に変換するツールをrpn2pnを作れ.

% rpn2pn "1 9 / 1 + 9 *"
* + / 1 9 1 9

--nobsun


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:26:34 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:55:28 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:15:18 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


2006-10-02 [JavaScript] IEで親ウインドウのtextareaのカーソル位置を取得する

IEでtextarea中のカーソル位置を取得するには、 KOSEKI Kengo氏のSelection.jsが使える。

http://www.teria.com/~koseki/memo/xbselection/

ただし、子ウインドウから親ウインドウのカーソル位置を取得しようとしても正常に動作しない。

var selection = new Selection(window.opener.document.getElementById('yourComment'));
var s = selection.create();
var pos = s.start;

上記でposは0になってしまう。

これを意図通り動作させるにはSelection.jsを書き換える必要がある。

Selection.prototype._ieGetSelection = function() {
    this.element.focus();

    var range = document.selection.createRange();

上記でrangeオブジェクトを生成するのにデフォルトのdocumentオブジェクトを使っているが、 これをターゲットであるtextareaの親のdocumentオブジェクトに変更する。

Selection.prototype._ieGetSelection = function() {
    this.element.focus();

    var doc = this.element.ownerDocument;
    var range = doc.selection.createRange();

要素の親のdocumentオブジェクトはownerDocumentプロパティで参照できる。

--yasuyuki


Name:
Comment:
vwvzksmoij: (Fri Oct 21 22:26:52 2011 )
csfhyptt, http://www.cfxuystaqi.com vkobuxxpuv
gcmcieqgdb: (Sun Nov 27 11:55:37 2011 )
fksgpptt, http://www.ydlxqucrmx.com wmbcvpjuxj
xsrxgrenae: (Sun Nov 27 21:15:22 2011 )
wjgklptt, http://www.achmzrtggu.com msaslzijtf


このサイトは、 IPA の「平成15年度オープンソフトウエア活用基盤整備事業」 の委託事業として開発されたKahuaで試験的に運用しております。

Copyright (c) 2004-2007 株式会社タイムインターメディア About Us