• Pyramid installation – “UnicodeDecodeError: ‘ascii’ codec can’t decode byte” error fix

    Pyramid installation – “UnicodeDecodeError: ‘ascii’ codec can’t decode byte” error fix

    Following pyramid framework installation notes I kept getting ‘ascii’ codec can’t decode byte error message. The whole error output looked like this:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    $ bin/easy_install pyramid
    Searching for pyramid
    Reading http://pypi.python.org/simple/pyramid/
    Reading http://docs.pylonshq.com
    Reading http://pylonsproject.org
    Reading http://docs.pylonsproject.org
    Best match: pyramid 1.4a4
    Downloading http://pypi.python.org/packages/source/p/pyramid/pyramid-1.4a4.tar.gz#md5=0a5da1a25791764cdfefb15b2d55656a
    Processing pyramid-1.4a4.tar.gz
    Writing /tmp/easy_install-hrcuuc/pyramid-1.4a4/setup.cfg
    Running pyramid-1.4a4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-hrcuuc/pyramid-1.4a4/egg-dist-tmp-kbuxa9
    Traceback (most recent call last):
    File "bin/easy_install", line 9, in
    load_entry_point('distribute==0.6.28', 'console_scripts', 'easy_install')()
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1929, in main
    with_ei_usage(lambda:
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1910, in with_ei_usage
    return f()
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1933, in
    distclass=DistributionWithoutHelpCommands, **kw
    File "/usr/lib/python3.3/distutils/core.py", line 148, in setup
    dist.run_commands()
    File "/usr/lib/python3.3/distutils/dist.py", line 917, in run_commands
    self.run_command(cmd)
    File "/usr/lib/python3.3/distutils/dist.py", line 936, in run_command
    cmd_obj.run()
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 358, in run
    self.easy_install(spec, not self.no_deps)
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 598, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 628, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 823, in install_eggs
    return self.build_and_install(setup_script, setup_base)
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1103, in build_and_install
    self.run_setup(setup_script, setup_base, args)
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1089, in run_setup
    run_setup(setup_script, args)
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/sandbox.py", line 31, in run_setup
    lambda: exec(compile(open(
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/sandbox.py", line 79, in run
    return func()
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/sandbox.py", line 34, in
    {'__file__':setup_script, '__name__':'__main__'})
    File "setup.py", line 122, in
    File "/usr/lib/python3.3/distutils/core.py", line 148, in setup
    dist.run_commands()
    File "/usr/lib/python3.3/distutils/dist.py", line 917, in run_commands
    self.run_command(cmd)
    File "/usr/lib/python3.3/distutils/dist.py", line 936, in run_command
    cmd_obj.run()
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/bdist_egg.py", line 172, in run
    self.run_command("egg_info")
    File "/usr/lib/python3.3/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
    File "/usr/lib/python3.3/distutils/dist.py", line 936, in run_command
    cmd_obj.run()
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/egg_info.py", line 179, in run
    self.find_sources()
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/egg_info.py", line 254, in find_sources
    mm.run()
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/egg_info.py", line 308, in run
    self.add_defaults()
    File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/egg_info.py", line 339, in add_defaults
    self.read_manifest()
    File "/usr/lib/python3.3/distutils/command/sdist.py", line 377, in read_manifest
    for line in manifest:
    File "/home/pootzko/env/lib/python3.3/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7896: ordinal not in range(128)

    …aaaaand it kept driving me nuts for a couple of hours until it finally came to me that the problem lied my locale setup and not in python setuptools. Simply typing:

    1
    export LANG='en_US.UTF-8'

    in terminal to change the encoding fixed the problem (keep in mind that this changed the locale temporarily only for the current session).

    Hope it saved you some time. Cheers!

  • autokana – jQuery plugin

    autokana – jQuery plugin

    Autokana is a jQuery plugin that automatically converts latin (roumaji) to kana (hiragana / katakana) using the auto-correct principle (keep in mind that it’s not suitable for converting copy/pasted but only typed-in text). You can check out how it works at autokana example page.

    You can also download the plugin (including a simple usage example) from github and use it for free.

    To use it, you will have to add the following somewhere at the beginning of your body tag:

    1
    2
    3
    4
    5
    6
    7
    <script type="text/javascript">
       // bind events when document is ready
       $(document).ready(function() {
          // attach auto-kana plugin with default options
          $("#kana_text_box").autokana();
       });
    </script>

    After that add the input box itself wherever you need it (make sure to use the same ID in the above part and in the input field itself):

    1
    2
    3
    4
    5
    6
    7
    <input id="kana_text_box" type="text" />
    <script type="text/javascript">
       // this part will clear and set focus on the input field on refresh
       // feel free to remove that part if you don't need it
       document.getElementById("kana_text_box").value="";
       document.getElementById("kana_text_box").focus();
    </script>

    If you have any suggestions or bug reports, feel free to leave a comment.

  • Mapping Japanese kana characters (hiragana/katakana) for use in programming

    Mapping Japanese kana characters (hiragana/katakana) for use in programming

    When I started working on Zanzou, I had to find a way to somehow map the whole kana so I could later use it in my webapp. I simply used 2D array to accomplish this. It’s no nuclear science but to save you the trouble of copying and pasting all the symbols into a single file yourself (I think it actually took me around an hour to do it :D), here is my kana.js file (note that if if you open the file itself in the browser, it will most probably display some strange characters instead of proper UTF-8 encoded kana symbols but when you open the file in your text editor, it should be usable and displayed just fine).

    I divided it into 4 major groups (arrays): monographs, digraphs, monographs with diacritics and digraphs with diacritics. Each array element (representing sound) consists of 3 subelements (roumaji record, and hiragana and katakana symbols).

    With some minor modifications, this could easily be used in any other programming language. Just make sure if you edit the file to save it in UTF-8.

    Hope it helps, がんばって!

  • cmik.fm at build.last.fm + source at github

    cmik.fm at build.last.fm + source at github

    cmik.fm made it into build.last.fm a few days ago, and not only that, but last.fm team rewarded me with a jolly good one year of free last.fm subscription as well, yaaay! thanks last.fm!

    I also decided to release the source-code for cmik.fm under GPL3 over at github for anyone interested (not that I see a good reason for anyone to look at it, but it just feels good to leave it out there). heh :D

  • Github “Permission denied (publickey).” fix

    Github “Permission denied (publickey).” fix

    Over at github troubleshooting page, there is some info about this issue, but since I haven’t used this way of authentication (public key) previously it took me a while to figure out why exactly I kept getting this message and why I failed to establish a connection with github. The thing is, I generated an RSA key-pair with a name different from the default “id_rsa” and because of that the ssh-agent did not have the key in its cache (thus I could not authenticate).

    To fix this, you can either use the default “id_rsa” for your key name (in which case it will be in ssh-agent’s cache automatically) or use “ssh-add your_key” command to add it to the cache.

    If you did the same funky key-naming thing as I did, I hope this helps and takes away your headache! =D

  • How to fix Ctrl-Tab behavior in Kate?

    Kate has tabs turned off by default (at least that’s what you get with vanilla Kate package from Arch Linux repositories) and even when you turn them on, they act kinda funky because Kate switches between tabs by name order, rather than by opening order so what happens is that Ctrl-Tab starts jumping between your tabs instead of going from one to another, from left to right. That was quite confusing to me, and I wanted to change that behavior to what I’m already used to in browsers, GEdit, Pidgin, whatever… Finding a solution (a very well camouflaged one for that matter, thank you) to this situation was rather… unexpected.

    To turn tabs on (if they’re not turned on by default in your distro) you will first have to go to Settings -> Configure Kate -> Plugins and turn on either “Tab Bar” or “Multiline Tab Bar”. Try both and then decide which one suits you better. After that you will have to set up the shortcut for switching between tabs. To do that, go to Settings -> Configure Shortcuts and set the shortcut for Forward to Ctrl-Tab. You could as well set up alternate shortcuts: Alt+1 for Back and Alt+2 for Forward. You will be able to toggle tabs in both directions then easily.

    To fix the tab switching behavior (ordering), open the Documents column from the File System Browser (if you have it turned off, turn it on under plugins), right-click on it and choose Opening Order from Sort By in the drop-down menu.

    That’s it, enjoy!

Back to top