CTWM Config Permalink

Linux, X Added a day ago

I have been using CTWM as my window manager on my Debian VM for a while now, here is the config (.ctwmrc) file. Put it in your home directory and adjust your .xinitrc accordingly.

The setup I have uses 4 workspaces, you can't drag windows off the screen and it has a simple menu mainly for launching xterms in nice places. It is setup for the resolution 1280x800 (my macbook.)

NoGrabServer
NoTitleHighlight
NoIconManagers
DontMoveOff
RestartPreviousState
DecorateTransients
TitleButtonBorderWidth 1
NoHighlight
BorderWidth 2
TitleFont       "-*-helvetica-medium-r-*-*-11-*-*-*-*-*-*-*"
ResizeFont      "-*-helvetica-medium-r-*-*-11-*-*-*-*-*-*-*"
MenuFont        "-*-helvetica-medium-r-*-*-11-*-*-*-*-*-*-*"
IconFont        "-*-helvetica-medium-r-*-*-11-*-*-*-*-*-*-*"
IconManagerFont "-*-helvetica-medium-r-*-*-11-*-*-*-*-*-*-*"
ShowWorkSpaceManager
WorkSpaceManagerGeometry "360x18+458+780" 4
WMgrButtonShadowDepth 0
WMgrHorizButtonIndent 0
WMgrVertButtonIndent 0
BorderWidth 1 
NoTitle { "WorkSpaceManager" "xterm" }

WorkSpaces
{
    ""   {"#5de100" "white" "black" "black" "black"}
    ""   {"#1f1ab2" "white" "black" "black" "black"}
    ""   {"#ffc200" "white" "black" "black" "black"}
    ""   {"#e7003e" "white" "black" "black" "black"}
}


Color
{
    BorderColor         "#ffc201"
    DefaultBackground   "black"
    DefaultForeground   "black"
    TitleBackground     "#ffc201"
    TitleForeground     "white"
    MenuBackground      "black"
    MenuForeground      "#ffc201"
    MenuTitleBackground "#ffc201"
    MenuTitleForeground "black"
    IconBackground      "black"
    IconForeground      "#ffc201"
    IconBorderColor     "black"
}

MoveDelta 3
Function "move-or-lower" { f.move f.deltastop f.lower }
Function "move-or-raise" { f.move f.deltastop f.raise }
Function "move-or-iconify" { f.move f.deltastop f.iconify }

Button1 = : root : f.menu "defops"
Button2 = : root : f.delete
Button1 = m : window|icon : f.function "move-or-lower"
Button2 = m : window|icon : f.iconify
Button3 = m : window|icon : f.function "move-or-raise"

Button1 = : title : f.function "move-or-raise"
Button2 = : title : f.raiselower

Button1 = : icon : f.function "move-or-iconify"
Button2 = : icon : f.iconify

Button1 = : iconmgr : f.iconify
Button2 = : iconmgr : f.iconify

menu "quit" {
    "Quit X?"   f.title
    "quit"    f.quit 
}

menu "defops"
{
"YourHost"     f.title
"(L) xterm"   f.exec "exec xterm -ls -fg gray -bg black -sl 500 +sb -geometry '104x57+0+18' &"
"(R) xterm"   f.exec "exec xterm -ls -fg gray -bg black -sl 500 +sb -geometry '104x57+648+18' &"
"(Big) xterm" f.exec "exec xterm -ls -fg gray -bg black -sl 500 +sb -geometry '212x57+0+18' &"
"gvim"        f.exec "exec gvim &"
#"conky"      f.exec "exec conky &"
"vm tools"    f.exec "exec vmware-toolbox &"
#"iceape"     f.exec "exec iceape &"
#"firefox"    f.exec "exec firefox &"
"kill"        f.destroy
"restart"     f.restart
"quit"        f.menu "quit"
}



iconv Unicode Converter Permalink

Shell Added a couple of days ago

I always forget what iconv is called, so this entry is just a memory assistant:

$ iconv -f ISO-8859-1 -t UTF-8 filename.txt



Using Git for Server Configs Permalink

Git, Shell, Apache Added a few days ago

I dev on a VM that has at least two projects running with incompatible apache httpd.conf files. The differences include User/Group, Location etc, so I switch between the configs and then restart apache httpd when I want to work on a particular project.

Firstly, I understand that some or all of my different settings could be merged into one conf file and made to work on different virtual hosts etc, but in some situations you can't do this because: you only want one project running off your dev server at a time due to performance/load issues; or you have a specific file you need to use as a httpd conf file from your codebase etc.

So - I used git to help me switch between configs.

# cd /etc/apache2
# git add apache2.conf
# git commit
# git tag projA
# vim apache2.conf # or cp your apache2.conf for projB into place
# git add apache2.conf
# git commit
# git tag projB
# echo "/etc/init.d/apache2 restart" > .git/hooks/post-checkout
# chmod a+x .git/hooks/post-checkout

... now you are setup! So when you want to switch to projA you do this:

# cd /etc/apache2 && git checkout projA

... and to switch back to projB use:

# cd /etc/apache2 && git checkout projB

... and your apache will automatically restart after each checkout.

Yes you could do this just by copying your files into place but I think this is a neat use of git and one that will scale over many projects and many revisions of the conf files.




Merging Changes using VimDiff Permalink

Vim Added about a week ago

Core Dump has a nice entry on this.

$ vimdiff file1 file2

Keyboard Shortcuts: do - Get changes from other window into the current window. dp - Put the changes from current window into the other window. ]c - Jump to the next change. [c - Jump to the previous change.




AnyEvent: Event Based Perl-Programming Permalink

Perl Added about a fortnight ago

You could use the ol' POE, or this new(ish) bad boy: AnyEvent

AnyEvent is different - it is a thin abstraction layer above all kinds of event loops. Its main purpose is to move the choice of the underlying framework (the event loop) from the module author to the program author using the module.

AnyEvent looks good and I'm going to have a play with it soon!




Extract Ranges Permalink

Perl Added about three weeks ago and last edited about a fortnight ago

I'm sure there is a module to do this already, but as as a Perl exercise this morning I wrote the below. It extracts specified arithmetic sequences from arrays of numbers:

#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

sub getr {
    my $inc = shift;
    my @list = @_;
    my @thislist;
    push(@thislist, shift @list);
    while (my $i = shift @list) {
        if ($i == $thislist[-1] + $inc) {
            push(@thislist, $i);
        }
        else {
            return ( \@thislist, getr($inc, $i, @list) );
        }
    }
    return \@thislist;
}

my @a = qw(1 2 3 4 7 8 9 11 12 16 18 20 21 22 25);
my @b = qw(2 4 6 8 10 11 13 15 17 19 20 21 22 24);
my @c = qw(10 7 4 1 -1 -9 -10 -11 -12 -15 -18);

my @lists = getr(1, @a);
for my $list (@lists) {
    print "Got: @$list\n";
}

print "\n---\n";

@lists = getr(2, @b);
for my $list (@lists) {
    print "Got: @$list\n";
}

print "\n---\n";

@lists = getr(-3, @c);
for my $list (@lists) {
    print "Got: @$list\n";
}

The output:

Got: 1 2 3 4
Got: 7 8 9
Got: 11 12
Got: 16
Got: 18
Got: 20 21 22
Got: 25

---
Got: 2 4 6 8 10
Got: 11 13 15 17 19
Got: 20
Got: 21
Got: 22 24

---
Got: 10 7 4 1
Got: -1
Got: -9
Got: -10
Got: -11
Got: -12 -15 -18

I'll clean it up and put it in a package soon - I think I will start keeping a personal code snippet/exercise git repo - it might be good to look back on as a journal!




Vim - What Changes Did I Make? Permalink

Vim Added about three weeks ago

If you open a file in Vim, make some changes, then want to check those changes compared to when you opened it (do a diff before saving), then you have a few options:

:w !diff % -

... is an easy one. Others include:

diffchanges.vim

DiffWithSaved function




Exoteric Permalink

English Added about a month ago

Today I learnt a new word: exoteric

Intended for or likely to be understood by the general public

The opposite of esoteric.




Perly Vim Permalink

Vim, Perl Added about a month ago and last edited about three weeks ago

Vim regexes aren't great, especially if you are used to Perl ones. When you are looking for a Perly way to substitute some text in Vim, try the simple:

:perldo s/something \d+/another/

This is a good way to make sure your ranges, special chars, character classes and flags etc work the way you have come to expect from using Perl.

By default this operation works on the entire file, but you can prefix the command with line ranges like you would with a normal Vim substitution.




pkgsrc on OS X Permalink

OSX, Shell, NetBSD Added about two months ago

I've tried fink and macports but found both of them very broken at some stages. They have quite recent ports in them though which is good... but not good enough when you look at how frequently they fell over.

It turns out the NetBSD port tree (pkgsrc) can be used on Mac OS X!

This page describes the process you need to install it.

Very nice!




Older Posts ... (Nothing Newer)

Colophon

Django, Python, 960.gs, Git, Vim, WebFaction

The Author

The author is a software engineer living in Australia. He sux at guitar, loves camping, doesn't like cake, does like coffee and is a lazy home brewer.

Meta

Help
Latest entries

*BSD Agile Apache Apple Athletics Beer Best-Practice Censorship Comedy Cool Django English Firefox Git Hardcore Javascript Languages Linux Mathematics MySQL NetBSD OSX Perl Photo Privacy Python Rant Requirements SQL SQLite SSH Shell Slackware Standards Subversion Testing ThisBlog VMWare (Fusion) VPN Vim WDTEM X

Recent Entries

CTWM Config
iconv Unicode Converter
Using Git for Server Configs
Merging Changes using VimDiff
AnyEvent: Event Based Perl-Programming
Extract Ranges
Vim - What Changes Did I Make?
Exoteric
Perly Vim
pkgsrc on OS X
Software Rewrites
Subversion Merging
Ginsberg Poetry Collection Photo
In the search of MD5(x)=x
Check for Hacks!!!!!111!
Matches Photo
"Hype" vs. "Publicity"
Not Being Involved in Estimates == Insanity
Cable Photo
Amp Photo

Links

ChoppingBoard, Project365, RageQuit

♥ Actors/Artists/Characters