rulururu

post OS X SVN Clients - SvnX & ZigVersion

January 21st, 2008

Filed under: SVN — zedr0n @ 1:38 pm

On windows the most popular client is TortoiseSVN, but the situation isn’t as clear on the mac.

SvnX

The first one i tried was SvnX. It’s free open-source subversion client which is quite popular.Read more…

ZigVersion

So I’ve decided to switch over to ZigVersion. It’s not open-source, but free for personal use which suits me just fine.Read more…

Conslusions

All in all, I do prefer Zigversion, though I’ll be on lookout for other mac svn clients - there is java SmartSvn and upcoming VersionsApp which looks quite promisiing. For now, the choice is yours what to use…

post Installing wiki on a2hosting with latex support on A2Hosting

January 20th, 2008

Filed under: A2Hosting — zedr0n @ 8:37 pm

Installing MediaWiki

Getting MediaWiki up and running is pretty simple. Here is the installation script which will download mediawiki 1-11.0 and do the necessary preconfiguration (see more here on that)

Setting up database for Wiki

Go to CPanel->MySQL Databases and add new database(e.g wikidb - I’m not sure but to be on the safe side I recommend to select name which isn’t the same as one of subdomains on your website). Then Add User(e.g wikiuse) and Add User to database with all privileges.

Configuring

You can try to do the first part automatically by running the script in the intended wiki directory - bash installwiki.sh
If everything went ok, then just point your browser to the config directory. Follow the direction on-screen - you should enter the data you used when creating the database in the Database config section - don’t forget to add your a2hosting username to db name and db username.
Now some postinstallation stuff

mv ./config/LocalSettings.php ./
rm -rf ./config

It will just delete ./config directory and move localsettings.php to its intended place

Enabling TeX

To enable tex you need to have texvc compiled in your wiki/math subdirectory. Unfortunately, a2hosting doesn’t have ocaml installed so you won’t be able to compile it on-site. But I managed to find the precompiled binary for CentOS 5 for x86_64 platform which is what a2hosting runs. You can grab it here. You’ll need to put it into your wiki/math subdirectory and maybe do chmod 777 ./texvc on it.
Then you’ll have to add the following lines(or change the value if they exist already) to your LocalSettings.php file

$wgUseTex = true;
$wgTmpDirectory = "/home/your_username/www/your_wiki_directory/images/tmp";
$wgMathDirectory = "/home/your_username/www/your_wiki_directory/images/math";

You’ll also have to actually create the directories in question by ssh’ing to your server and executing

cd ~/www/your_wiki_directory/images
mkdir tmp
chmod 777 tmp
mkdir math
chmod 777 math

post Setting up single-user synced SVN repositories

January 17th, 2008

Filed under: Coding, SVN — zedr0n @ 9:30 pm

First you’ll need to follow the SVN wiki entry to set up svn repository and passwordless ssh access at A2Hosting.

As this is only for one user, then the easiest way is to use svn dump functionality which allows for incremental dumps. Using post-commit hooks we’ll just save the new commits since last sync to a dump file. Furthermore, apart from manual update of repositories from dump we’ll also write a script which will sync the repositories nightly(e.g using cron). But the main thing is to be able to switch from using remote(main) repository to its local copy to continue developing if for some reason we don’t have network access.

Setting up repositories

I assume that you’ve got one repository completely set up and ready. Now we only need to dump the repository,

svnadmin dump repository_path >dumpfile

copy the dumpfile and run

svnadmin create repository_path
svn load repository_path <dumpfile

Setting up automatic dumping

The next thing is installing post-commit hook, which is just an executable program put into repository_path/hooks. Consult post-commit.tmpl for more info.
post-commit

#!/bin/sh
REPOS="$1"
REV="$2"
DUMP=path_to_dump_to

svnadmin dump $REPOS --incremental --revision $REV >$DUMP/newsvn.dump
cat $DUMP/svn.dump $DUMP/newsvn.dump >$DUMP/svn_.dump
mv -f $DUMP/svn_.dump $DUMP/svn.dump

And don’t forget to make it executable with chmod.

Synchonizing the repositories

This is the script to sync from remote to local
sync2local

#!/bin/bash
FTP_USER=
FTP_PASS=
FTP_SERVER=
SSH_SERVER=
SSH_USER=
DUMPFILE=svn.dump
REPO=/svn
PORT=-p 7822

#delete old dump file
if [ -e $DUMPFILE ]; then
    rm $DUMPFILE
fi
#get current dump file
wget --password=$FTP_PASS --user=$FTP_USER ftp://$FTP_SERVER/$DUMPFILE
if [ $? != 0 ]; then
    echo No dumpfile available
    exit
fi

#update local repository
svnadmin load $REPO <$DUMPFILE

#delete dump file if sucessful
if [ -e $DUMPFILE ]; then
 ssh $SSH_USER@$SSH_SERVER $PORT rm $DUMPFILE
 rm $DUMPFILE
fi

And the script to sync from local to remote
sync2remote

#!/bin/bash
FTP_USER=
FTP_PASS=
FTP_SERVER=
SSH_SERVER=
SSH_USER=
PORT="-p 7822"
REPO=
#dumpfile with full path
DUMPFILE=
#test if dump file exists
if [ ! -e $DUMPFILE ]; then
    echo "No dump file available"
    exit
fi

#upload dump file
echo "put $DUMPFILE $(basename $DUMPFILE)" | ftp ftp://$FTP_USER:$FTP_PASS@$FTP_SERVER
if [ $? != 0 ]; then
    echo "Can't upload dumpfile"
    exit
fi
#update remote repository
ssh $SSH_USER@$SSH_SERVER $PORT "svnadmin load $REPO <$(basename $DUMPFILE)"
#delete dump file if sucessful
rm $DUMPFILE
ssh $SSH_USER@$SSH_SERVER $PORT rm $(basename $DUMPFILE)

Switching between repositories

These 2 scripts svn2remote and svn2local can be used to switch a working copy between repositories. Before switching it will sync to the most recent copy, which is precisely what we need.
svn2remote

#!/bin/bash
REPO=/svn
sync2remote
svn switch --relocate file://$REPO svn+a2hosting://zedr0n@quant0r.com/home/zedr0n/svn .

svn2local

#!/bin/bash
REPO=/svn
sync2local
svn switch --relocate svn+a2hosting://zedr0n@quant0r.com/home/zedr0n/svn file://$REPO .

So, basically, whenever you want to work on some projects, you just check it out by doing svn2local and merge the changes with svn2remote when you are done. If you are confident in remote repository then you can just work with it all the time. It’s quite flexible really…

post Installing OpenID with WordPress

January 16th, 2008

Filed under: A2Hosting — zedr0n @ 5:14 pm

The first part is to allow openID users to post comments on your blog, this can be easily achieved by installing Wordpress OpenID plugin. The installations is simplicity itself - just copy the plugin and activate it, nothing else required.

The other part is being able to use your blog as an openID server. I wasn’t able to find this as a plugin so I decided to go with a standalone
phpMyID. Grab the 0.7 beta here and follow the instructions in README file, they are pretty straightforward and they worked for me with no problems.

Just to note that if you want it to work with your wordpress blog you need to add to the header.php file of your current theme

<link rel="openid.server" href="http://<your-blog>/MyID.config.php" />
<link rel="openid.delegate" href="http://<your-blog>/MyID.config.php" />

If your blog is on a subdomain then MyID.config.php and MyID.php should be uploaded to the subdomain root(i.e. your-domain/subdomain).
Otherwise if you just put it into your root, it will point to your openID server - i.e. the root of your domain

post Custom refresh of NetNewsWire with AppleScript

January 16th, 2008

Filed under: Coding, mac — zedr0n @ 5:00 pm

I’ve switched to mac just recently and haven’t yet found the alternatives for all the windows tools. I’ve been trying Newsfire for some time and I’ve been somewhat satisfied with its performance. But since I’ve discovered Wilmott Forums RSS feeds I was having problems with Newsfire - it doesn’t change status, nor in any other way acknowledge small item updates. And as Wilmott goes with the one-item-per-thread model, so that the item just contains the date of the last post, it was more or less useless for with Newsfire.

Then NetNewsWire went freeware, so I decided to give it a try. It has a useful feature - “mark updated items as unread” while also sorting the items by the last update time, which is more or less what I need. Although, I need to say that it doesn’t mark items as unread after tiny updates - as on Wilmott, so it’s not ideal. One other problem with NetNewsWire is that the minimum refresh time is set to 30 minutes. While it might be acceptable to most feeds so as to not get distracted all the time, I want to get faster wilmott updates. Well, when there’s a will, there’s a way. And this way is called AppleScript.

Skip down for new beta of custom refresh app

The first, and by far simpler, way is to use a script. It’s pretty straightforward - just open up Script Editor and insert

repeat
  tell application "NetNewsWire" to refreshAll
  delay 300
end repeat

I’ve settled on 300 seconds for delay time, but whatever one wants. Now, running the script manually, looks like a chore and it still shows up as a window. So, to improve it, we can do File->Save As->application bundle. Still not much improvement so far, we can’t even quit the app. But we don’t really need it if we hide it. And it can be easily achieved by adding to /NameOfApp.app/Contents/Info.plist

<key>LSUIElement</key>
<string>1</string>

This key tells the app to work in background/dockless mode, which is precisely what we need. The cpu usage is quite modest indeed, so we can just add it as a Login item and all’s done. The NetNewsWire now refreshes as fast as we want it too.

The second way is for those who just need to be able to stop refreshing without resorting to Force Quit. It’s a bit harder, and involves using XCode.
The standard way to automate actions in Os X so far seems to use Automator, and NetNewsWire is no exception. Unfortunately, the number of actions available is rather limited, and no refresh/refreshAll action available. But we can create a new action on our own. To do this, simply do
XCode->New Projects->New AppleScript Application. Now the files we need are main.applescript, Info.plist, InfoPlist.strings. The script is just

on run {input, parameters}
    tell application "NetNewsWire" to refreshAll
    return input
end run

Now, if we switch to Release mode and build the app, the only thing left to install the action is to copy from project directory to either /Library/Automator or ~/Library/Automator. It will show up in Automator but as a separate action unrelated to NetNewsWire, it will work, but it does annoy a bit. That’s why we’ll need Info.plist - we change AMApplication key to

<key>AMApplication</key>
<string>NetNewsWire</string>

And that’s all we need to do for the app to show under NetNewsWire. To clean up things a bit, we can also edit InfoPlist.strings

AMName = "RefreshFeeds";
/*  AMDescription localized strings  */
AMDSummary = "Refresh all feeds";

Everything else there is irrelevant for our purpose.

The only thing left is just to create an Automator workflow of the format:

  • NetNewsWire-> _our new action to refreshAll in NetNewsWire_
  • Automator->Pause
  • Automator->RunWorkflow

Now we can save the workflow as application and apply the same trick with LSUielement. The only difference is on the menu bar
Menu Bar refresh

We can stop it at any time by pressing the red button. The disadvantages with this approach is 5-10 times bigger cpu usage(well, under 1% still) and clutter on the menu bar - but whatever one prefers…
You can download both apps here - script RefreshRSS and Automator RefreshFeeds

Thanks to a request from Theodora I’ve tried to improve the script a bit to allow for custom subscription refresh. It’s beta for now, so any comments are highly welcome, though it should work ;) So, what’s in the Refresher.app? It’s still just a script as RefreshRSS but with a few tweaks. Upon launch you’ll get a dialog in NetNewsWire asking

netnewswire001.jpg

If you click yes, then you’ll get a list of all your subscriptions where you need to choose the one you wish to set/change the refresh rate, it looks smth like this
netnewswire002.png

If you select the subscription you haven’t previously set the refresh rate for you’ll just get a dialog box
netnewswire003.png

The default value is 5 minutes; pressing ok will bring you again to the dialog box asking if you want to add another refresh rate.

If for whatever reason you want to change the refresh rate for subscription you just select it from the list and get a dialog box like
netnewswire005.png

That’s pretty much it. For technically oriented, this is pure AppleScript, all the details of your subscriptions are stored in ~/Library/Preferences/Refresher.info in format “Subscription:refresh time” on every line.

You can get it here : Refresher.zip

p.s. If you are getting error message “file Macintosh HD: … is already open” then this means that app crashed earlier and you’ll have to reboot to close it properly. Anybody knows how to close file opened with open for access under applescript for that matter?

post Setting up Latex with WordPress on A2Hosting

January 16th, 2008

Filed under: A2Hosting — zedr0n @ 12:20 pm

A good thing is that latex is already installed by default on the server.You can check it by logging to the server with ssh and typing “latex”

You should get smth like

xxx@yyy.com [~]# latex
This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)

Now we need to install Steve Mayer’s LatexRender plugin. To simplify the installation I used the bash installation script from Gunnlaugur Þór Briem.

Unfortunately, for some reason, the access to wget is denied to me, while curl is ok - go figure. You can check if it works for you by ssh again. In my case it just gives

xxx@yyy.com [~]# wget
-jailshell: /usr/bin/wget: Permission denied

While you are at it, check that curl is available by typing “curl”

xxx@yyy.com [~]# curl
curl: try 'curl --help' for more information

Now you can grab the updated installer script from this post - LatexRender installation script. Copy it to your /wp-content/plugins directory and run it from there.

xxx@yyy.com [~/www/blog/wp-content/plugins]# bash install-latexrender.bash
Commands latex and dvips are present.
Commands convert and identify are present.
Current directory seems correct.
Installing with BLOG_URL_BASE ''
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 20761  100 20761    0     0  83637      0 --:--:-- --:--:-- --:--:--  141k
Installing into directory latexrender
Installing with beta vertical-offset-tweaking functionality
Setting up correct php file paths and HTTP virtual paths
Setting up correct paths to tex commands and ImageMagick commands
Correcting bugs in the offset beta code
Correcting transparency bug
Plugin setup complete.
Now go to WP admin, Plugins panel, and activate the plugin LatexRender.

After activating the plugin in WordPress, the latex support can be easily obtained by using tex tag, for example

[tex] \int xdx = \frac{x^2}{2} [/tex]

will promptly show   \int xdx = \frac{x^2}{2}

P.S. If you are interested what’s the other difference in my version of installer script it also corrects the bug in offset_beta, where the ‘\’ signs weren’t all escaped. Specifically, ‘\f’ wasn’t escaped and this led to it disappearing(e.g. \formulawidth changed to ormulawidth in .tex file).
Also transparency didn’t seem to work with black on white(maybe it’s just my theme) so I had to negate the image before making it transparent…

ruldrurd
© quant0r.com , Designed by Stealth Settings
Entries (RSS) and Comments (RSS)