Sunday, June 13, 2010

MAC認証セキュリティシステム(三井情報のSAS)でのDHCP不良

三井情報のSASを導入してから下記の現象が見られました:
24時間以上使っていないPCの電源を入れるとIPアドレスを取得するには4〜8分かかります。
いろいろ業者と相談してもなかなか解決できなかったが、やっと分かりました。
MAC認証システムは、最小に仮IP(10.255.255.x)を与えます。このIPからDHCPREQUESTを出すとdhcpサーバから見ると依頼元のネットワークが間違っています。そこにこの解決の鍵がありました。

内のdhcpサーバが業者の下請けによってインストールされてのですが、dhcpd.confの中で「non-authoritative」になっていた。そうなりますと、10.255.255.xからのDHCPREQUESTがnon-authoritativeの理由で無視される。dhcpd.confで一番上の行にauthoritativeにすると、「wrong network」のログエラーが出ます。その直後DHCPNAKとDHCPDISCOVERがありますから結局IPアドレスを1分以内に取得できる。

要するに、MACアドレス認証システムを使っていれば、dhcpdサーバのdhcpd.confがauthoritativeになっていないとうまくいかない。

When using a MAC address recognition security system which gives a dummy IP to the client while checking the MAC registration status, make sure that the DHCP server's dhcpd.conf has "authoritative" as the first line. If it doesn't, the DHCP request from the dummy network is ignored, and the next DHCPDISCOVERY doesn't come for about four minutes or so.

Saturday, April 17, 2010

Setting Keyboard Layout in WinXP, Vista, and Win7

Regedit

Go to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters



For JIS keyboard layout:

値の名前 : 値の種類 : 値のデータ

LayerDriver JPN : REG_SZ : kbd106.dll

OverrideKeyboardIdentifier : REG_SZ : PCAT_106KEY
OverrideKeyboardSubtype : DWORD : 2

OverrideKeyboardType : DWORD : 7



For US keyboard layout:


LayerDriver JPN : REG_SZ : kbd101.dll

OverrideKeyboardIdentifier : REG_SZ : PCAT_101KEY
OverrideKeyboardSubtype : DWORD : 0

OverrideKeyboardType : DWORD : 0

Wednesday, September 30, 2009

Make Windows XP Japanese recognize US 101 keyboard

This is from http://digital.ni.com/public.nsf/allkb/CC58BBDC801BB536862575210020234A reprinted here so that I can find it easily.

1.キーボードを日本語配列から英語配列のもに変更する方法

・デバイスマネージャで、キーボードに割り当てられているドライバを日本語キーボードから英語キーボードに更新してください。
・コントロールパネルの地域と言語のオプションから、言語タブを選び、"テキスト サービスと入力言語" の "詳細" ボタンをクリックし、"US" や米国、英語などの英語配列キーボードのサービスを追加してください。

以上の設定で、通常の半角文字の入力モードのキーボード配列が英語配列に変更されます。

2.日本語入力モードで、英語のキー配列を使用するための設定

上記の設定だけでは、日本語入力モードにした際にキー配列が日本語に戻ってしまう場合があります。その場合は、以下の手順にしたがって、レジストリを編集してください。

・スタートメニューから、ファイル名を指定して実行を選び、"regedit"と入力して、レジストリエディタを開きます。
・[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters] レジストリを選択します。
・以下のキーの値の名前を右クリックし"修正"を選択し、変更します。

※詳しくは下記リンクのMicrosoft社ページを参照下さい。

LayerDriver JPN → KBD101.DLL (KBD106.DLLになっている可能性があります)
OverrideKeyboardIdentifier → PCAT_101KEY (PCAT_106KEYになっている可能性があります)
OverrideKeyboardSubtype → 0 (2になっている可能性があります)
OverrideKeyboardtype → 7 (8になっている、もしくはキーがない可能性があります)

上記の編集が終わったら、レジストリエディタを終了し、Windowsを再起動します。

Saturday, January 3, 2009

Undergraduate intro to IT syllabus, a list of requirements for computer and internet literacy

I am trying to gather ideas on the skills and concepts that should be considered mandatory for first-year college students. I have seen teachers do everything from demonstrating the mechanics of hard disk drives to spending two weeks on typing, and in many Japanese colleges, computer literacy is a just a class on using Microsoft Office. Please post what you think should be taught in an Introduction to IT. Also feel free to post summaries of what you have seen people teach in Intro to IT. This discussion began as a thread on the schoolforge-discuss@schoolforge.net mailing list, which is "An open forum for discussing topics related to education, FLOSS, and technology trends" hosted at http://www.schoolforge.net/.

Wednesday, November 12, 2008

A subjective review of database modeling software

Background

I maintain and continue the development of an administrative database for the small college where I work. As part of a proposal for a Monbukagakusho grant (Japan's national department of education and science, among a few other things), I am proposing to have some outside developers help me to rewrite our db app in Ruby on Rails. I chose ROR because of the overwhelming community of Rubyists here in Kyushu, and I chose to hire developers because I will be learning Ruby from scratch and need to get this done fast.

The developers told me that they needed something more detailed than the .dot file (Graphviz) and the HTML documentation that is produced by our current framework, ERW. They suggested ERWin, which is over 100,000 yen (one thousand dollars) even with an educational discount. So I asked http://www.experts-exchange.com/ and combed the search engines for recommendations. I tested quite a lot of software, and these are my disorganized findings and recommendations.

Criteria

I have a large database with lots of unused tables and some design problems that need to be fixed. I need software that can accurately reverse engineer my current database so that I don't have to do everything by hand. I also need good printing capabilities.

My db is running on Postgresql7.3 on an intranet Apache RHEL3 server. I tried quite a few programs and lost a lot of time trying to make things work with my database in its current version. Support personnel from MicroOLAP and from ModelRight told me flat out that most software won't support reverse engineering from Postgresql 7.3 and that the ODBC drivers for 7.3 are not very good. They suggested that I pg_dump the db structure and install on Postgresql8.2 or 8.3, so I set up EnterpriseDB's one-click Postgresql package on my Windows VM and then tried them all again.

Findings

Toad Modeler (http://www.toadsoft.com/toaddm/toad_data_modeler.htm) was my first test. It does not support Postgresql 7.3, so I could not try it after I first installed it. I found a download for its previous version, x-casestudio, which does support 7.3. However, the company wouldn't give me a trial key, so I couldn't try that out, either. After I finally got the database duplicated on Postgresql8.3, the Toad trial period (less than the 30 days offer by other software) had ended, so I never got to try Toad. Toad does seem to have a lot of documentation online and a community, including screencasts, so it looks like it would be worth looking into.

I spent a long time trying MicroOLAP Database Designer for Postgresql (http://www.microolap.com/products/database/postgresql-designer/). I experimented and sent in bug reports to them as I tried to get it to work with my Pg7.3 db. Even then, it engineered nicely but crashed when I tried to save. When I finally installed Pg8.3 and tried it, I found it to be responsive, light, and graphically very easy to look at. It supports Postgresql natively and correctly reverse engineered everything. The support staff was very good, too, and the president of the company even responded to an email with advice and a coupon code for half price (making it about 70 USD). The relationship lines are drawn really well, by which I mean that when you move a table around, the links move with it, and they never bunch up or overlap, and lines automatically bend at right angles at places and go diagonal at others. The drawback to MicroOLAP was the lack of an explicit cardinality determination on the relationship properties. It is not obvious how to declare two tables in a IS_A relationship, which is 1:1, for example. I assume that it is done by setting the Null and Unique properties on the foreign keys in the child table, but that would be better as a property of the relationship. For traditional ERD with Postgresql, this was my favorite.

I installed and used HappyFish (http://www.polderij.nl/happyfish/) for a while. It is really, really easy to use, has great printing capabilities, and it offers all the features you need. The UI is intuitive and snappy, and support for Happy Fish was really good, too. The online docs are a little lacking, but the condemning factor for me was the fact that the relationship lines are straight and bend at right angles. They also snap to the grid, so a diagram of any complexity ends up having overlapping relationship lines and becomes hard to understand. Other than that, great software, and it pulled my db out through ODBC even with Pg7.3 pretty well.

I tried ConceptDraw (http://www.conceptdraw.com/en/products/cd5/main.php) and was happy to see that it is Mac-PC, so I installed it on the Mac but couldn't find the macro that is supposed to reverse engineer databases. ConceptDraw support informed me that this feature is only available on Windows, so I installed it on my Windows VM and tried again. It took a very long time to reverse engineer, and when it was done, there were no relationships. The other drawback to ConceptDraw is that the ERD it makes is just a diagram, without detailed properties. But I must say that if you are not reverse engineering and not working with a really, really large and complex database, ConceptDraw is a very good buy because it is very useful for other illustrations and diagrams. I still might consider ConceptDraw because one purchase would give me a great program for documenting our campus network, organizational flowcharts, and team processes for us in grant proposals like the one I am working on now. Fabulous website and really good tutorials and screencasts.

ModelRight (http://www.modelright.com/) is really good, in many ways. They have a Community edition with a smaller feature set for free, and they have a free read-only version that you can give to clients and contractors who don't own ModelRight so that they can inspect your models. I love this idea and hope that others emulate it. The view options and the customizations are great, but what I liked most of all was that ModelRight has a really active online community with forums and tutorials, so you will get prompt support and advice. It is a really good deal. However, ModelRight also failed to reverse engineer my relationships, though the soon-to-be-released version 3.5 (support said it will take a few more months) Postgresql version of ModelRight will probably do this better. For generic db ERD, ModelRight would be a very good buy. With a proactive support crew, a great online community, and a very feature-rich and easy-to-use interface, I think 3.5 will be my favorite ERD tool, but I cannot wait a few months, so the search goes on.

ERCreator (http://www.modelcreator.com/) has a lot of users, and it seemed pretty good on the website, but when I tried to reverse engineer from the 7.3 and then from the 8.3, it just froze. I had to use Process Explorer to kill it. Sorry that I cannot evaluate it, but it choked and died three times on me. I don't think I have done it justice, so do try it yourself.

A member of experts-exchange.com named "thewild" suggested Enterprise Architect (http://www.sparxsystems.com.au/), so I gave it a shot. It offers the features that other systems offer, but it is also a full-featured UML 2.1 modeling program. There are many versions, each of which is offered with educational discount for as low as 60USD. Another plus is that Sparxsystems offers EALite, which, like the lite version of ModelRight, is a free read-only program that allows clients and contractors to inspect your models.

EA reverse-engineered my db and the relationships just fine, but the resulting diagram was not an ERD, and I am ashamed to say that intimidated me. I studied database design formally and have read two different editions of Date's Intro to Database Systems and enjoyed it both times. I honestly enjoy relational databases, Venn diagrams, and set theory. I really like Chen ERDs, and I feel so confident with them that I sketch them free-hand when talking about domain issues with users. However, EA did not produce Chen but UML Data Modeling Profile (UML-DMP).

The EA help system states that EA implements the UML Data Modeling Profile, which is not yet ratified as UML but is widely used and pretty much is closer than any other UML database modeling framework to becoming an official part of UML, and UML itself is on the way to being an ISO standard. But I am in a hurry to get this done, and I don't know UML at all, so I was even more intimidate. I could not figure out what all these properties options were, and I didn't want to make a fool of myself. Because I am in a hurry to finish this diagram and get a formal estimate, I put down EA and went back to MicroOLAP.

But the issue stuck with me, and I read the EA Help system's explanation of the UML-DMP (http://www.sparxsystems.com.au/resources/uml_datamodel.html), and then I looked it up online and found a couple of informative articles.

Donald Golden at http://findarticles.com/p/articles/mi_qa4041/is_200604/ai_n17186203/pg_1?tag=artBody;col1 describes why Cleveland State University made UML their modeling tool for all information science classes, including database design. CSU students use UML in database design, software design, and networking classes, which means that they can construct a UML project that includes all aspects of a complete system and describes how the parts interact.

Fred Lewis at http://wescosoftware.com/papers/umldbase.html goes into the nuts and bolts of how UML replaces the ERD and expands on the information that can be modeled.

Conclusion

While ModelRight has the most features, it does not yet support Postgresql natively and did not successfully reverse engineer my db, leaving MicroOLAP the best candidate among the ERD tools. However, Enterprise Architect (EA) is not an ERD tool, so I was actually faced with a choice between ERD MicroOLAP and UML EA. ERD tools, and in particular Postgresql-specific tools like MicroOLAP can help you maintain and administer a database through the program, generating and applying SQL modification code through the diagramming software itself. This is something that EA does not offer. However, EA opens the door to the rewarding (if labor-intensive) acquisition of a new skill set and the possibility of applying UML to other parts of your work.

So I am going to go with Enterprise Architect, but I should make clear the misgivings I have about it:
  1. Printing: The printing system is not as easy to use as the ERD tools. Most of them have a page boundary layer on the screen that lets you see how many pages the diagram will take and even arrange the tables so that they don't break across pages. ModelRight, HappyFish, and MicroOLAP do this really well. EA's printing system allows you to specify how many pages wide and high of what size page to fit the diagram into, but you cannot prevent graphics being on the edges between pages.
  2. Speed: The software is slow. I am using an XP VM on Parallels under Mac, but I have given the VM 64 MB of video ram and 2GB of RAM, and EA is still jerky and slow. Where MicroOLAP and ModelRight tables glide across the screen under your cursor, EA lets you move a blank frame and then the table jumps into place; also, moving a table to the edge of the screen to scroll to an unused piece of drawing space takes a long time. Actually, all scrolling and panning takes too long and is jerky. Also, after clicking a class or attribute in the navigation panes there is a little lag before something happens. I would love to see EA speed up.
  3. Navigation: Zoom and span capability is a little lacking. The span and zoom window is fine, but you have to move the cursor over there and use the slide bar or move the frame in the window. Other tools let me use the mouse wheel to scroll up and down (no modifying key), left and right (when holding shift), and zoom in and out (when holding Ctrl), which is much more efficient and faster.
These issues aside, I am choosing and recommending EA because, for a very small fraction of the cost of Rational Rose or other enterprise-scale program, you will get a fully UML2.1-ready UML diagramming tool that also does the new Data Modeling Profile and can reverse-engineer existing databases and generate SQL to create databases. The price list at http://www.sparxsystems.com.au/products/ea/purchase.html lists the Desktop version at 135 USD, and the educational pricelist at http://www.sparxsystems.com/products/academic_pricing.html lists it at 65 USD. Also, choosing EA for database diagrams means that I will have to learn something new in order to use it. That is a burden but also a plus, because in addition to enlarging my skill set, this opens the door to using UML for other things, like network diagrams and organizational process analysis.

I finally chose to get into using UML for database modeling as a means to develop professionally and satisfy my interest in UML, but this might also mean getting in early on the next evolution in database modeling and design.

Friday, December 28, 2007

HowTo: Django Dev Environment on MacOSX Tiger using MacPorts

The Mac uses Python in the OS itself, so messing with the system Python can be risky, and Apple has a bad reputation for compliance with the official Python, because the earlier versions of OSX shipped with broken Python installations, and even recent versions of OSX ship with modified versions of Python.

MacPorts can give you a consistent django dev environment with easy upgrades, but you have to be conscious of which Python you are calling and make sure your PATH variables are set correctly when making scripts, using IDEs, and so on. MacPorts offers a django port, so you could feasibly set up everything through MacPorts, but I set up django with subversion here.

MacPorts
  1. Install MacPorts from the Mac OSX package.
Python Environment and Postgresql
  1. Macports treats each piece of software as a "port," and it downloads the source, compiles, and then installs the software for you. MacPorts also installs dependencies for you, so if you tell MacPorts to install port C, which is dependent on A and B, MacPorts will install A, B, and C.
  2. In order to make sure that your MacPorts has the latest info, update it with:
    sudo port sync
  3. For Django, we need a DBMS, and I choose Postgresql. We need psycopg to link it to Python, so let's first find out which postgresql, python, and psycopg ports are available:
    sudo port search postgresql
    sudo port search python
    sudo port search psycopg
  4. A little research reveals that, as of this writing, the differences in Python 2.4 and Python 2.5 have necessitated that the MacPorts project separate related ports into those beginning 'py-' for Python 2.4 and 'py24-' for Python 2.5. So since I want to use Python 2.5 with Postgresql, I will need to use py25-psycopg2.
  5. The port maintainer decides the dependencies of the port she maintains, so the dependencies of py25-psycopg2 will determine the version of Postgresql to be installed:
    sudo port deps py25-psycopg2
  6. Though postgresql82 is the newest version, py25-psycopg2 depends on postgresql81, so that is the one I will go with.
  7. So let's start with the database server:
    sudo port install postgresql81 postgresql81-server
  8. Now we need to install Python 2.5:
    sudo port install python25
  9. And now the library that allows Python and Postgresql to communicate:
    sudo port install py25-psycopg2
  10. Technically, this is the minimal set of parts needed for django, but the MacPorts version of Python includes only the essentials, leaving it to the user to add modules, and some of these excluded modules are needed to really use Django. First install py25-hashlib to accommodate Django's authentication module:
    sudo port install py25-hashlib
  11. Next, install py25-readline if you want the interactive interpreter to be usable at all (backspace, delete, etc.):
    sudo port install py25-readline
  12. Another recommendation is to install iPython, which is an enhanced Python interactive shell. While I would not bother if I had to manually configure Django to work with iPython, I recommend it here because (1) iPython is multi-platform and (2) Django was modified to call iPython, if found, and only if not found to call the regular interactive shell.
  13. Then install other modules you might need:
    sudo port install py25-bz2 py25-zlib py25-crypto py25-chardet py25-dateutil py25-socket-ssl
  14. Though postgresql is installed, it is not really set up yet. For the sake of easy management, I want to keep all user databases in /Users/DB/postgresql, so first make that dir:
    sudo mkdir /Users/DB/postgresql
  15. Now we go to Netinfo Manager to find out what user (and group) MacPorts installed for postgresql. It should be user postgres, but my install resulted in the following, so I give it a password :
    username: postgres81
    group: postgres
    passwd: agoodpassword
  16. Make PostgreSQL binaries available to user by adding to PATH in ~/.profile:
    echo 'export PATH=$PATH:/opt/local/lib/postgresql81/bin' >> ~/.profile
  17. Since PostgreSQL will run under postgres81 user, we need to make it own the postgresql directory:
    sudo chown -R postgres81:postgres /Users/DB/postgresql
  18. Initialize the PostgreSQL master database. We are starting PostgreSQL as user postgres81, so we use sudo to elevate privileges; use su to assume the user we want, then use -c to tell su to execute a command as user postgres81:
    sudo su postgres81 -c "initdb -D /Users/DB/postgresql"
  19. Add postgresql start and stop commands to profile:
    alias pgstart="sudo su postgres81 -c 'pg_ctl -D /Users/DB/postgresql -l /Users/DB/postgresql/logfile start'"
    alias pgstop="sudo su postgres81 -c 'pg_ctl -D /Users/DB/postgresql stop -m fast'"
    alias pgstatus="sudo su postgres81 -c 'pg_ctl status -D /Users/DB/postgresql'"
  20. Now logout and log back in, then create a role (user) in postgres with the same name as the login who will use it:
    sudo su postgres81
    createuser -s -P -l
  21. Part of the MacPorts install adds the dir for the MacPorts apps to the PATH:
    # Setting the path for MacPorts.
    export PATH=/opt/local/bin:/opt/local/sbin:$PATH
  22. However, when calling python from the command line, you will still get the Tiger default Python 2.3 because the MacPorts Python executable in /opt/local/bin is named python2.5, so make a symbolic link so that a call to 'python' will give you 'python2.5':
    sudo ln -s /opt/local/bin/python2.5 /opt/local/bin/python
Django source files
  1. Now that Python 2.5 and Postgresql are set up, it is time to install the Django source files. First, use the shell to find the site-packages dir for Python:
    python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
  2. Assuming you set the PATH correctly, the default MacPorts Python 2.5 install should give you:
    /opt/local/lib/python2.5/site-packages
  3. You can install the django source right there in site-packages, or you can install them in a separate directory and make a link. For my purposes, I want a dir for web dev, and inside it a dir for django, and inside that I want to install the django source code, so let's create that nested dir:
    mkdir -p ~/Webdev/django/src
  4. Next, move to the source dir and use svn to check out the dev trunk of django in this dir. This command will create a dir containing the dev version. This is the core code of django, and it will be kept separate from the projects that will be created with django:
    cd ~/Webdev/django/src
    svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk
  5. Create a symbolic link to the django source in the site-packages dir:
    sudo ln -s ~/Webdev/django/src/django-trunk /opt/local/lib/python2.5/site-packages
  6. Create a symlink to make sure that the Python interpreter can load the django code:
    ln -s /opt/local/lib/python2.5/site-packages/django-trunk/django /opt/local/lib/python2.5/site-packages/django
  7. On Unix-like systems, first check your $PATH and then create a symbolic link to django-admin.py in a directory on your system path so that you don't have to type the full path when invoking it, so if `echo $PATH` shows that /usr/bin is in your path, you can make a link:
    ln -s /opt/local/lib/python2.5/site-packages/django-trunk/django/bin/django-admin.py /usr/bin
  8. See if `ls -l /usr/bin/django-admin.py` gives you something like:
    lrwxr-xr-x 1 root wheel 78 Dec 29 12:39 /usr/bin/django-admin.py -> /opt/local/lib/python2.5/site-packages/django-trunk/django/bin/django-admin.py
  9. The sites you make in Django are stored separate from the Django code, and all of this is outside of your public_html or /var/www directories. I choose to keep my projects in the django webdev dir:
    mkdir ~/Webdev/django/sites/
First project according to Django Tutorial
  1. Move to the sites dir and create a new project:
    cd ~/Webdev/django/sites/
    django-admin.py startproject mysite
  2. If postgresql is not running, turn it on and then login to psql:
    pgstatus
    pgstart
    psql template1
  3. In psql, create postgresql role django to use for django and then create the unicode database mysite with django as owner:
    create role django with superuser createdb login password 'agoodpassword';
    create database mysite encoding='UTF8' owner=django;
  4. Edit djangotests/mysite/settings.py, specifying:
    DATABASE_ENGINE = 'postgresql_psycopg2'
    DATABASE_NAME = 'mysite'
    DATABASE_USER = 'django'
    DATABASE_PASSWORD = 'agoodpassword'
    TIME_ZONE = 'Asia/Tokyo'
  5. Make sure you are in the project dir and then start the dev server included with python:
    cd ~/Webdev/django/sites/mysite
    python manage.py runserver
  6. Check the following link to make sure the django dev server is running on localhost:
    http://127.0.0.1:8000/
  7. Run the script to create tables for installed apps listed in settings.py:
    python manage.py syncdb
  8. This creates the tables needed for your test project. Use psql to take a look. Earlier, you created a superuser with the same name as the MacOSX login you are using, and you created the django user and the mysite database with django as the owner, so you should be able to access and examine the mysite database:
    psql mysite
  9. Use /dt in psql to describe tables (see all the tables in the database you are using), and use /d tablename to examine individual tables.
  10. From there, just follow the tutorial.