attribute: Phillie Casablanca

sqlite, zlib not working on centos

Playing around with centos, and have been working to get python 2.6 installed.
(Centos defaults to 2.4)

I managed to download and install python 2.6 using:


sudo ./configure
sudo ./make altinstall

However, when I tried to install additional packages I hit a zlib error.
I remembered that sqlite3 was also an additional package and checked and that failed as well.


>>> import zlib
ImportError: No module named zlib

>>> import sqlite3
ImportError: No module named _sqlite3

I found this post which mentioned zlib-devel, and found that installing that and sqlite-devel did the job.

So just run:


sudo yum install zlib-devel
sudo yum install sqlite-devel

# change to python directory
cd Python*
sudo ./configure
sudo make altinstall

And now both modules can be loaded properly.
altinstall will automatically install python to be python2.6.
This allows you to maintain the 2.4 build that centos needs for various system tools.

monkut // June 23, 2010 // 12:37 a.m. // 1272 Comments

creating pdfs with Japnaese text using sphinx/pdflatex

This describes the process for preparing a setup on windows that can create PDF containing Japanese from sphinx output *.tex file.

Installation Steps
====================

1. Create C:\w32tex directory

2. Create C:\w32tex\archivedpackages directory

3. Download "texinst757.zip" from http://www.fsci.fuk.kindai.ac.jp/kakuto/win32-ptex/web2c75.html

4. Unzip "texinst757.zip" into C:\w32tex

5. Download ALL files from the "最小インストール"(Minimal Install) and "標準インストール" (Standard install) lists and place them in C:\w32tex\archivedpackages

6. In addition download the following packages from the "フルインストール" (Full Install) list
- ums.tar.gz
- omegaj-w32.tar.gz
- ttf2pt1-w32.tar.bz2
- utf.tar.gz -- not sure if it's needed
- uptex-w32.tar.bz2 -- not sure if it's needed

7. Download and install ghostscript ftp://akagi.ms.u-tokyo.ac.jp/pub/TeX/win32-gs/gs863w32full-gpl.zip
1. Check the "Use Windows TrueType fonts for Chinese, Japanese and Korean" option and Install into C:\w32tex\gs

8. Download and install IPA fonts from http://lx1.avasys.jp/OpenPrintingProject/openprinting-jp-0.1.3.tar.gz
1. Drag and drop the *.ttf files found in the archive to the Windows/Fonts directory.
- this will install the fonts on the pc

9. Run the following command:

texinst757.exe C:\w32tex\archivedpackages

NOTE: This will take some time

10. Add the following to your system path:

- C:\w32tex\bin
- C:\w32tex\gs\gs8.63\bin
- C:\w32tex\gs\gs8.63\lib

11. Download ftp://cam.ctan.org/tex-archive/macros/latex/contrib/titlesec.zip, unzip and copy the titlesec folder to C:\w32tex\share\texmf\latex\

12. Run the following command (You may need to restart your console in order to take the new path settings into effect)
- This command will search and update fonts/styles (*i think*) that were added in step 11.

texhash

Done!

Converting Sphinx *.tex output to PDF
========================================

Now that you have w32tex installed, you still need to adjust some of your process in order to create a pdf properly.
Note: I'm using sphinx 0.6.1

1. In your conf.py add/uncomment the latex_elements and update to look like this:

latex_elements = {
'preamble': '\usepackage{ums}\input jpdftextounicode\pdfgentounicode=1',
'inputenc': '',
'fontenc': '',
'fontpkg': '',
}

2. Build your *.tex file using sphinx.
- My source files are utf8, and I believe sphinx outputs the *.tex to utf8.

3. Convert the output text to cp932 encoding
- Ideally, topdftex.exe/pdflatex.exe support utf8, but I haven't figured this out, so this is currently a workaround step

import codecs
import shutil
utf8_f = codecs.open("sphinx_output.tex", "rb", "utf8")
cp932_f = codecs.open('sphinx_output.cp932.tex', 'wb', 'cp923')
cp932_f.write(utf8_f.read())
utf8_f.close()
cp932_f.close()

4. Run topdftex.exe on the converted output, renaming to the orignal *.tex name.

topdftex.exe sphinx_output.cp932.tex sphinx_output.tex

5. Run pdflatex.exe on the final output, sphinx_output.tex.

It was quite a struggle to get this far, I hope this helps others.

monkut // May 9, 2010 // 9:40 p.m. // 227 Comments


Vista File Sharing-Round 1

I finally got a wifi router that supports windows file sharing!!!

Now I can finally 'easily' share files between home machines.

Or so I thought...

It looks easy enough, make sure your set for a private network, turn on file sharing, turn off password protection (in my case) from the Network Properties.

Then find the folder you want to share, right-click, 'Share', follow the dialog and your done right?

Not for me.

When tried to browse my media pc (pc where sharing is configured) from my laptop I was initially happy to see the pc when I opened 'Network' from the file explorer. With my previous router I didn't even see it show up. Double clicking on the media pc opened a login dialog. Ok, I read looked up and read the microsoft help on this (see link below) and found that I should just enter 'guest'.

http://technet.microsoft.com/en-us/library/bb727037.aspx#EDAA

No luck... I can 'see' the folder I set to share now, so I guess I'm successfully logged 'in' to the pc, but when I try to open the folder I get an access error.

Ok, so it does mention I may need to add 'guest' to the share permissions. So through the share permissions I found add user and added 'Guest', set the permissions and tried again... same thing.

Here's the secret, are you ready?

Then, on the folder properties, 'security' tab, I also added the 'Guest' user, and applied permissions.
This opened the gate for me! And I'm now able to share files through this folder vista-machine to vista-machine.

Round 2, configure our xp laptop to access the vista machine.
(I'm praying it won't be too painful, this took me about 2 hours...)

monkut // Jan. 9, 2010 // 9:15 a.m. // 1091 Comments

Djangoで動的にフォーム(Form)のフィールド(field)を作る

Djangoの遊びプロジェクットをやっています。

そこで、ユーザが入力する項目から、複数選択可能チェックボックスのFormが作りたくて困っていました。

下記のモデルを定義しました:

models.py


class SkillCategory(models.Model):
name = models.CharField(max_length=50)

class Skill(models.Model):
category = models.ForeignKey(SkillCategory)
name = models.CharField(max_length=50)

Djangoの開発者らしいサイトから、So you want a dynamic formでの説明から、下記の答えがわかりました。

ここで、モデルで定義するSkillやSkillCategoryから、FormのFieldが動的に作成されます。
forms.py


from django import forms
from myapp.models import Skill
def get_categorized_skills():
    skills = {}
    for s in Skill.objects.values('pk', 'name', 'category__name').order_by('category__name'):
        if s['category__name'] not in skills.keys():
        skills[s['category__name']] = []
        skills[s['category__name']].append((s['pk'], s['name']))
    return skills

class SkillSelectionForm(forms.Form):
    def __init__(self, *args, **kwargs):
        super(SkillSelectionForm, self).__init__(*args, **kwargs)
        skills = get_categorized_skills()
        for idx, cat in enumerate(skills.keys()):
# ascii以外(日本語)の名前が使えるようにfield_name・display_nameを作成します。
field_name = u'category-%d' % (idx)
display_name = cat
            self.fields[field_name] = forms.MultipleChoiceField(choices=skills[cat],
label=display_name,
widget=forms.CheckboxSelectMultiple)

monkut // Sept. 13, 2009 // 10:07 p.m. // 713 Comments

Fight with La Fonera

I use a "La Fonera" router at home, and have been tackling trying to get file-sharing working across it with a home server.

Configuration options are sparse on the thing and the only promising approach is "port forwarding".
However, poking around at it for awhile and doing some searches it looks like "windows file sharing" isn't supported.

I ran across FreeWLAN, which looks like it might allow windows file sharing, but since the english documentation is near nil and I'm not 100% sure it will do what I want, I didn't want to deal with flashing firmware.

At them moment I am able to FTP to the home server, but this method seems a little archaic for 2009.
May be it's time to buy a different wifi router, any suggestions?

monkut // Sept. 12, 2009 // 1:10 p.m. // 241 Comments