Valkertown Blog

I used to write about electronics…

Valkertown Blog header image 4

More on MUDs and the SMC

June 19th, 2009 by Carlos Perilla
Respond

MUDs are composed of several interconnected rooms that overall create a complete world on which a virtual avatar develop it’s adventures andinteract with objects and other players. One of the hardest(funnest also?) part of playing this kind of games is that the user needs to
navigate this maze of rooms with little or no help at all. Players have to memorize paths and landmarks and a well seasoned player might have
almost every room mapped on his head, but this is a long and treacherous process since MUDs change constantly; they are text based the
creator can do in text everything he wants, so it’s fairly mutable and unpredictable.

Writing aiding tools for these games can be as hard as the MUD creator wants, after all he can write in natural language and he can change the
game without affecting the human understanding or the game mechanics but force the player to rewrite the tools he might be using. Because of this, separating the parsing from the logic process for the tools is a mayor priority that needs to be adresses to create a powerful tool that can be shaped accordingly as the MUD changes over time.
[Read more →]

Tags: Comments

Stackless MUD Client

June 13th, 2009 by Carlos Perilla
Respond

Well I’m going to release today a small project I have been working for a while, it’s a mud client written in stackless python.

I’t going to be hosted in bitbucket, I’m giving this service a try even when I use to host my own repositories for this, if I don’t like how it goes there I’ll switch back to my own hosting.

Here’s the link: SMC Bitbucket

I decided to write it on stackless python because I wanted to write few complex bots using a FSM design methodology since I consider it’s the best approach for MUDs, and writing these with stackless python would be far easier than with the bare python.

So far it satisfies my mudding needs and I keep writing more and more bots and extending the ones I have.

Since this is the first announcement of the client it’s in a very internal state, I cleaned up a bit the files and added license header for each of the files but overall it needs a lot more documentation.

I hope someone gives it a try, for one I’m happy to have a MUD Client with a decent programming language to write my stuff.

Tags:   · · · · Comments

Uzbl Browser

June 9th, 2009 by Carlos Perilla
Respond

Recently I have found uzbl while trying to look a vimperator(firefox) replacement that didn’t waste so much resources and be as slow as
firefox has gotten. Well we will have firefox 3.5 that would solve several of these issues and even then I will keep using uzbl for my
main browsing needs.

Uzbl is another webkit based browser that is as small and usable as I like my applications, pretty much
like Awesome it requires a fair amount of configuration but when you’re finished no other browser will match the user friendliness of uzbl for you.

Basically everything can be tailored and there’s no UI wasting space in your monitor, that’s one of the reasons I used vimperator for
firefox in first place. While keeping the config file in a clean text file that you can version control and share like I’m going to do now.

[Read more →]

Tags:   · · · · Comments

Setting up Redmine with archlinux Part 2

April 14th, 2009 by Carlos Perilla
Respond

On the previous part we downloaded the source and setup the system so can being setting up everything.

To be honest Apache is not really required at all on this setup, it was required for me since I run other stuff on the same server, so let’s begin with it.

All that we need is to setup a reverse proxy on apache like this:

  1. <VirtualHost *:80 >
  2.     ServerName redmine.somewhere.net
  3.     <location /sys>
  4.         Order allow,deny
  5.         Allow from 127.0.0.1
  6.     </location>
  7.     ProxyPass / http://localhost:3000/
  8.     ProxyPassReverse / http://localhost:3000/
  9. </VirtualHost>

One important thing is to deny access to /sys to everywhere but from localhost, we use it to query redmine from localhost but restrict the outside.

Now, redmine is a project management but not a frontend so our users can access the repositories so we do this also on apache, hgweb.cgi and hgwebdir.cgi whose are written in python.

  1. <VirtualHost *:80>
  2.     DocumentRoot "/path/to/hgweb/"
  3.     ServerAlias hg.somewhere.net
  4.     RewriteEngine On
  5.     RewriteRule ^/static/(.*)$ /static/$1
  6.     RewriteRule ^/(.*)$ /cgi-bin/hgwebdir.cgi/$1
  7.     RewriteRule ^/$ /cgi-bin/hgwebdir.cgi
  8.     <location />
  9.     Authtype basic
  10.     Authname "Somewhere"
  11.     AuthUserFile /path/to/somewherepasswd
  12.     Require valid-user
  13.     SetEnv SCRIPT_NAME "hg.somewhere.net"
  14.     AddHandler cgi-script  .cgi
  15.     Options +ExecCGI
  16.     </location>
  17. </VirtualHost>

I would suggest using ssl for this, I did setup the paswords for this since we use this setup for some private repos, also I like using subdomains for the different parts, but you can move the relevant stuff here inside a location clause.

Hgwebdir.cgi knows how to publish several mercurial repos, we have to configure it with hgweb.config on the same directory where hgwebdir.cgi is:

  1. [collections]
  2. /path/to/repos/ = /path/to/repos/
  3. [web]
  4. style = monoblue

I have a cronjob on /etc/cron.hourly/repos.sh that creates repos and generate the passwd file for hgweb so users can use the same password on redmine and hgweb. I prefer having write access to the repositories using ssh but this resulted far easier to coordinate and teach to new users than ssh, at least I could setup this withing ssl.

  1. #!/bin/sh
  2. ruby /path/to/redmine.svn/extra/svn/reposman.rb –redmine redmine.somewhere.net –svn-dir /path/to/hgrepos/ –owner apache –url /path/to/repos –scm mercurial –command "hginit" >> /var/log/repos.log
  3.  
  4. python /path/to/genhtpasswd.py > /path/to/somewherepasswd 2> /dev/null

I can’t remember if I wrote this script from scratch but I remember hacking a lot of it: genhtpasswd.py, note the explorer:somepass since it’s required so redmine can access the repos and acquire the data it needs.

  1. #!/usr/bin/env python
  2. import MySQLdb
  3. from hashlib import sha1
  4. from base64 import b64encode
  5.  
  6. conn = MySQLdb.connect (host = "",
  7.                         user = "",
  8.                         passwd = "",
  9.                         db = "")
  10. cursor = conn.cursor ()
  11. cursor.execute ("SELECT login,hashed_password from users")
  12. row = cursor.fetchone ()
  13. # Repo explorer password for redmine
  14. print "explorer:somepass"
  15. while row:
  16.     user = row[0]
  17.     password = row[1]
  18.     if user != "" and password != "":
  19.         phash = ""
  20.         while len(password):
  21.             c = int(password[:2],16)
  22.             password = password[2:]
  23.             phash += chr(c)
  24.         password = b64encode(phash)
  25.  
  26.  
  27.         print "%s:{SHA}%s" % (user,password)
  28.     row = cursor.fetchone ()
  29. cursor.close ()
  30. conn.close ()

Finally we get into redmine, first email, this requires a patch to redmine, so it can hanlde auth over ssl smtp. (I have to elaborate on this, but I haven’t the resources to do it at hand so I’ll let it for a future edit. Meanwhile google should suffice I’m really sorry)

email.yml

  1. production:
  2.   delivery_method: :smtp
  3.   smtp_settings:
  4.     address: "smtp.gmail.com"
  5.     port: 25
  6.     domain: "somewhere.net"
  7.     authentication: :login
  8.     user_name: "redmine@somewhere.net"
  9.     password: "yourpassword"
  10.     tls: true

I’ll skip database.yml since it’s not relevant, setup as you like but take note that genhtpasswd.py needs to be setup and modified accordingly to this config file.

Finally standing over the svn checkout of redmine, assuming you run Redmine with a user named redmine:

  1. $mkdir tmp
  2. $sudo chown -R redmine:redmine files log tmp
  3. $sudo chmod -R 755 files log tmp

Another note, keep in mind that the environment you configured in the rednime yml files is the one you need to start, so for me it’s production.

  1. $rake db:migrate RAILS_ENV="production"
  2. $rake config/initializers/session_store.rb
  3. $mongrel_rails start -e production

I wonder if I left something behing, if you notice something is missing or unclear please nag me and I will correct or elaborate on it.

Tags:   · · · · · Comments

Writting Circular Lists in Erlang

March 18th, 2009 by Carlos Perilla
Respond

Well I have been struggling to find/create a circular buffer(list to be exact) on erlang, but I’m still not satisfied, I have hacked this:

  1. [_P | T ] = lists:reverse(O),
  2.     N = [ V | lists:reverse(T)],

To insert V in the head and remove P from the tail. But can you see the problem with that: Two list reverse operations, that to me seems like expensive operations, maybe I’m not understanding fully the erlang’s lists module but I can’t find other way to do this using lists.

I know several other ways to implement circular buffers using arrays, one even might think using queues for what I need this buffer, but I need to remove any index from the buffer so lists makes a lot more sense than any other data structure.

Well I’ll be glad if someone enlightens me with another solution
EOP

Tags:   · Comments

Last time I logged into MS Windows(tm)

February 26th, 2009 by Carlos Perilla
Respond

Two years ago and a laptop ago I booted into windows, and noticed it was still showing the Packard Bell desktop also that I had barely installed anything on it. I had been using the laptop for like six months.

After realizing that I thought, this is stupid, I could use this space for something useful.

So I did: Reboot, fdisk, mkreisesrfs, vim fstab, mount -a and there you go, fresh new space for multimedia files.

On this laptop, that OS hand’t a chance. Two partitions: one small for easy boot and the rest just a big lvm storage that I can mess as much as I want.

Nowadays I log into Windows on other machines for various reasons but I find myself thinking. Why you have to use the mouse so much? I feel clumsy and that I spend way too much time doing simple tasks. Why the harddisk is always being hit? Why it’s so needy with all those popups?

I’m glad that a friend of mine showed me that with proper software setup and installation even windows can have a decent ui, finally my poor deepsabbath can get an usable workstation for hers Industrial Design tasks.

But. Hey, it’s software isn’t? I’ll be worried the day we can’t change the way our software behaves.

EOT

Tags:   · Comments

Denting-mode mercurial repository

February 20th, 2009 by Carlos Perilla
Respond

Well I have setup a proper repository to track the changes to denting-mode, I have received a patch from Christian Cheng with some really nice and welcome changes:

  1. Support Laconica deployed to a context that is not the root.
  2. Support retrieval of the public timeline.
  3. Fixed to handle wierd characters in response body.
  4. Enhanced to show no. of characters exceeding message limit

The url of the repo is http://hg.valkertown.org/denting-mode.hg/

I guess this will make easier to everyone to work and hack with denting-mode.

Enjoy!
EOP

Tags:   Comments

Small updates for denting mode

February 17th, 2009 by Carlos Perilla
Respond

I have just added a small modification to denting-mode:

  1. (defun denting-update-status-from-region (beg end)
  2.   (interactive "r")
  3.   (if (> (- end beg) 140) (setq end (+ beg 140)))
  4.   (if (< (- end beg) -140) (setq beg (+ end 140)))
  5.   (denting-update-status-if-not-blank (buffer-substring beg end)))

This small function will try to post to laconica the region, if the
region is over 140 characters it will cut it down to 140 characters left
to right.

Now I have setup a couple of keybindings on my .emacs so I can dent
stuff from my emacs buffers

  1. (define-key global-map "\C-c\C-d" ‘denting-update-status-from-region)
  2. (define-key global-map "\C-c\C-s" ‘denting-update-status-interactive)

The updated version it’s here:

http://hg.valkertown.org/denting-mode.hg

Tags:   · · · Comments

Emacs Denting mode for laconicas (including identi.ca)

February 16th, 2009 by Carlos Perilla
Respond

Denting Mode

I guess one of the main advantages that laconica has is being twitter compatible because if you have the source you can get a twitter only app to work on any laconica instance, so I found the twittering mode for emacs here:
http://lambdarepos.svnrepository.com/share/trac.cgi/browser/lang/elisp/twittering-mode

Then I decided to port it to laconica so I could use it to post to Brainbird, which is my own laconica instance.

I added the denting group for customization and I would like to use a password system like the one that weblogger.el uses. Now you can set the laconica instance you want to use by setting the laconica-instance variable.

The bindigns as always with emacs modes are the most sexy part, so here they are. I added none Im just posting this to make it easier for the interested to get to know which they are.

  1.      (define-key km "\C-c\C-f" denting-friends-timeline)
  2.       (define-key km "\C-c\C-s" denting-update-status-interactive)
  3.       (define-key km "\C-c\C-e" denting-erase-old-statuses)
  4.       (define-key km "\C-m" denting-enter)
  5.       (define-key km "\C-c\C-l" denting-update-lambda)
  6.       (define-key km [mouse-1] denting-click)
  7.       (define-key km "\C-c\C-v" denting-view-user-page)
  8.       ;; (define-key km "j" next-line)
  9.       ;; (define-key km "k" previous-line)
  10.       (define-key km "j" denting-goto-next-status)
  11.       (define-key km "k" denting-goto-previous-status)
  12.       (define-key km "l" forward-char)
  13.       (define-key km "h" backward-char)
  14.       (define-key km "0" beginning-of-line)
  15.       (define-key km "^" beginning-of-line-text)
  16.       (define-key km "$" end-of-line)
  17.       (define-key km "n" denting-goto-next-status-of-user)
  18.       (define-key km "p" denting-goto-previous-status-of-user)
  19.       (define-key km [backspace] backward-char)
  20.       (define-key km "G" end-of-buffer)
  21.       (define-key km "H" beginning-of-buffer)
  22.       (define-key km "i" denting-icon-mode)
  23.       (define-key km "s" denting-scroll-mode)
  24.       (define-key km "t" denting-toggle-proxy)
  25.       (define-key km "\C-c\C-p" denting-toggle-proxy)

The icon mode is nice, since it displays in recent emacs the avatars ofthe laconicats youre following. You can download the denting-mode.el here:

http://hg.valkertown.org/denting-mode.hg

If you hit one of the many bugs this code might have, please comment here and I might try to solve it. But bear with me Im not an usual emacs lisp programmer and this quialifies more to a hack than a proper release.

Tags: Comments

First post

February 1st, 2009 by Carlos Perilla
Respond

Well this is my first post of the year and Im glad I found lt;a href=quot;http://blog.nethazard.net/emacs-weblogger-mode-with-wordpress-tags-support/quot;gt;Emacs Weblogger with Tagslt;/agt; for wordpress, WP 2.7 dashboard is cute but an online editor will never be as good as emacs or it will be so easy for me to create a blog post even when using firefoxs its all text.

I have been working a while testing strophe a javascript library for xmpp. Its really insteresting how using xmpp you can create applications that interact with users in realtime with little overhead. After some time of testing and some examples I can say setting up something like speeqe its quite simple with strophe. Now I would like to start seeing more complex applications, maybe one that uses PUBSUB. On the downside of strophe is that the documentation is seriously lacking and you might want to read other examples in other frameworks and be sure to know how to deal with XEP so you can get the most if and get some ideas of what you can do.

Ill be posting the second part of the previous post about setting lt;a href=quot;http://blog.valkertown.org/2008/12/21/setting_up_redmine_with_archlinux/quot;gt;Redmine in Archlinuxlt;/agt;, with my particular setup. I think it would be handy when I need to setup it again.

So thats all for now, once again Ill try to update sooner.

Tags:   · · · · Comments