jump to navigation

Actionscript 2 with UTF8 and BOM May 25, 2010

Posted by maxmil in : Flash , add a comment

This none has had me baffled for a while….

My AS2 source code files are all UTF-8. However in one of these i have extended characters (its a function that strips accents and the like from a text string).

With MTASC compiler this was working just fine but with the MMC compiler String.indexOf does not work.

After some poking i have found the problem. In order for flash to compile the files correctly it need the Byte Order Mark (BOM) to be included in all Unicode files.

No idea if this is still the case with AS3.

Right click on HP Mini with Ubuntu UNR February 27, 2010

Posted by maxmil in : HP Mini, Ubuntu , add a comment

Just bought a notebook: HP Mini 210-1015es.

Installing Ubuntu Network Remix was a doddle however it has the mouse buttons integrated into the touch pad and they don’t get recognized.

This is not a problem for the left click since you can just tap the pad however there was no right click.

You can activate the right click by telling the psmouse that you have an exps mouse. You just create /etc/modprobe.d/psmouse.modprobe and add the following line:

psmouse proto=exps

However this means that you loose the touch pad functionality like the scroll as you move down the pad. Grrrrrr. Can’t i have the best of both worlds?

Setting up developer permissions on apache February 26, 2010

Posted by maxmil in : Apache, Debian , add a comment

I’m administrating a small server that hosts various web sites on an apache. Each web site has a group of developers who update their sites via ssh or sftp.

I needed to set up their permissions so that only the developers of each site and the apache user (www-data) could modify their sites files.

Each site is in a different sub directory of /var/www.

Initially, for each site, i created a group, put the developers of the site and the apache user in this group and gave the owner and group read and write permission on all the files.

This worked fine until a developer added files to the site since the new files were created with the developers principal group which meant the other developers could not edit the file.

Since each developer can be working on more than one site i could not just change the developers group.

However chmod g+s came to my rescue. This forces the all files created in each site to have the same group as the top level directory of the site.

Great.

However i still had a problem. The default umask for the developers that connected to the server was 022 which meant that even though the new files they created had the correct group the group only had read access to the files :(

With ssh connections changing the default umask was easy. I could do it in /etc/profile for the whole system or in ~/.profile for each user.

However when they connected via sftp this had no effect.

I think that the correct way to set up the default umask is using pam but after trying all sorts of configurations i couldn’t get it to work.

In the end the solution was to modify the line in /etc/ssh/sshd_config that started the stfp server.

#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp /opt/sftp-server-wrapper.sh

and create a wrapper script /opt/sftp-server-wrapper.sh

umask 0002
exec /usr/lib/openssh/sftp-server

Don’t forget to add execution permissions to the wrapper script, otherwise sftp just fails silently!

This works but if anyone out there has a cleaner solution i would be very happy to hear it!

Debian Java Socket Problems and IPV6 January 7, 2010

Posted by maxmil in : Uncategorized , add a comment

After my last system update all java code that attempted to connect to remote sockets started failing. Having tried everything, including pulling my hair out, i finally found the solution here

There are two solutions

1) Set bindv6only to 0
sudo sysctl net.ipv6.bindv6only=0
2) Everywhere you start a virtual machine (tomcat, eclipse, maven etc) pass a vm parameter
-Djava.net.preferIPv4Stack=true

Using limit in mysql join December 18, 2009

Posted by maxmil in : MySql , add a comment

Just found myself in the scenario of needing to join two tables which have a 1 – n relationship. In the second table i only wanted to return the first two results.

This is one way to do it.


SELECT
f1.col1,
f1.col2
FROM foo f1
LEFT JOIN foo f2 ON f2.col2 = f1.col2 AND f2.col1 < f1.col1
GROUP BY f1.col1, f1.col2
HAVING COUNT(f2.col1) <= 1
ORDER BY f1.col2, f1.col2;

What you are doing here is joining the second table with itself. This will give you exactly one result with the first row in the second table, two for the second row, three for the third... etc.

You then group them and use the HAVING clause to get the row that you want.

This is not very efficient, but if your dataset is small or it's a one off query it does the job.

Import Git to Subversion October 6, 2009

Posted by maxmil in : git , add a comment

There are lots of docs out there for how to use git-svn starting with a subversion repository that already exists, however not so many if you are starting with a git repository that you want to import into subversion.

I still consider myself a beginner with git but here is how i managed it.

1) Create and import an empty subversion repository.mkdir tmp
mkdir tmp/my-project
mkdir /my-project/trunk
mkdir /my-project/tags
mkdir /my-project/branches
svn import tmp http://some/svn/repo -m "Initial import"

2) Clone a git repository from the subversion one you just importedgit svn clone -s http://some/svn/repo/my-project(The -s tells git svn that you are using a standard layout for branches, tags and trunk).

3) Enter your new svn enabled git repositorycd my-project
4) Add your working git repository as a remote repository.git remote add dev /path/to/working/git/repository
5) Pull all the commits from your working git repository into the master branch of the new repostory.git pull dev master
6) Rebase these commits ontop of the initial svn commit.git svn rebase
7) Commit changes to svn.git svn dcommit (Note that you can use the -n option to check first the commits that are about to be committed).

And that should do it, you can now remove the remote repository dev from your new svn enabled repository and carry on working using git svn dcommit to push local changes to the subversion repository.

GIT: Setting up new remote repo August 28, 2009

Posted by maxmil in : git , add a comment

This is quick reminder for me of an excellent article from Toolman Tim.

Set up the new bare repo on the server:
$ ssh myserver.com
Welcome to myserver.com!
$ mkdir /var/git/myapp.git && cd /var/git/myapp.git
$ git --bare init
Initialized empty Git repository in /var/git/myapp.git
$ exit
Bye!

Add the remote repository to your existing local git repo and push:
$ cd ~/Sites/myapp
$ git remote add origin ssh://myserver.com/var/git/myapp.git
$ git push origin master

Set the local master branch to track the remote branch. Copy the following into ./git/config

[branch "master"]
remote = origin
merge = refs/heads/master

Using spaces in fstab August 6, 2009

Posted by maxmil in : Debian , add a comment

I frequently have to mount windows file systems that have spaces in their names.

If you put something like//path/to/windows/file system /local/mount/pointin ftstab it complains with

line XX in /etc/fstab is bad

The solution is to use the escape code \040 instead of the space//path/to/windows/file\040system /local/mount/point

Allowing remote access to MySQL server on Debian July 15, 2009

Posted by maxmil in : Uncategorized , add a comment

By default MySQL on Debian is configured to only allow local access. If you try to access from another machine you will get the following error:

Can’t connect to MySQL on (10061)

In order to allow remote access you must edit /etc/init.d/my.cnf and change the bind address from 127.0.0.1 to your local ip address.

List all files in directory tree by modification date April 1, 2009

Posted by maxmil in : Debian , add a comment

find app -type f -printf "%T@\t%t\t%p\n" | sort -r -n