Anything code related I want to retain.
Definitely the most popular page on my site, my Final Year Project was an ambitious plan to create a Game Boy Advance ↔ PC communications link that worked via USB. The project was a success, created using hobbyist electronics (a MicroChip™ PIC-chip and a more specialised by easily-obtained USB bus-interfacing chip). This basically involved assembling some hardware and then implementing the USB specification in a firmware which ran on this hardware.
All my code and notes area available, but by far the most popular area are the project report and it's accompanying disc content (complete source trees and such), the master schematic for the hardware and my project journal (which, though unorganised and hard to read, is very worth while when searching for answers about USB development).
So, if you are considering working on a USB device as a hobby or perhaps as an academic project, you may find some useful information in my USB project.
At the time of writing (Feb 2006) my project report is being downloaded 35 times per day on average.
I've written a rather lovely (PERL) script to rename my TV & Anime series either by copying'n'pasting from a website which lists the episode titles (such as AniDB or TV.com), by providing the script with the URL of the appropriate page on one of these sites, or by leaving it to search the sites it supports on your behalf and using whatever result it gets.
There are many examples of how this works and how to use this script on it's page.
Check it out: File renaming script.
I made a nifty Flash menu system for ChrisWhiteConservative.com1), it's so easy to use that I simply had to put it up here.
It was my first serious attempt of creating some ActionScript in Flash, and it worked quite well. There is some commented code to do nifty colour effects, but I didn't use them in the end. The menu data is fed to the script from a text file by the name of menu.txt, which is placed in the root of the site (this can easily by altered in the ActionScript to be what ever you want). The menu from the site I made was as follows:
menu= Welcome! Information News;http://www.bbc.co.uk Theme People Meet Chris Video and Interview Biography Gallery Policies Personal Local National Interactive Forum;http://www.phpbb.com Quiz Competition Join Us Events Membership / Donate Contact www.Conservatives.com;http://www.Conservatives.com
For clarity, this only includes a few (harmless) links. As I hope it obvious, you simply indent child items under their parents, and you make links by adding a semi-colon (;) and link at the end of a line. That's it. You update the menu.txt file and the menu changes when it is next loaded (assuming you're browser didn't cache this file).
Grab the original Flash MX document (.fla), Shockwave flash movie (.swf) and sample menu (menu.txt) file in this handy .rar file, made using my, now legitamate, copy of WinRAR!
While I was webführer of www.animesoc.co.uk I created a modification for phpBB which extended the rank system which comes as standard to allow progression along multiple path: genres.
For instance you might have the following rank system:
| Genre | |||
|---|---|---|---|
| Posts | 1984 | Corporate | Academia |
| 0 - | Proletariat | Temp | Fresher |
| 100 - | Outer Party | Contractor | Second Year |
| … | … | … | … |
| 4000+ | Big Brother | Chief Executive Officer | Chancellor |
Each of these genres has a different name for what is effectively the same social standing in the community, and each instance can have a different picture.
Check it out: phpBB Rank Genre MOD
Here's a handy replacement expression (i.e. substituting regular expression) you can use to convert a list into a lookup table.
In this particular instance, I wanted to convert the text-field “properties.area” into a lookup table “property_areas”, so this was the code to make the insert / update SQL.
From: ^(.*)$ to: INSERT INTO property_areas SET id=\i, area='\0';\nUPDATE properties SET area=\i WHERE area='\0';
This was used in Textpad (in POSIX mode), so I am not sure if the “\i” is available in other flavours. It means “incremented sequential”, specifically it goes 1, 2, 3… in this case — once per line, so even though the above refers to “\i” it is only incremented on each match, not each replacement.
Note: This is obsolete to me now, as I've become a VIM fiend!
Stuff I'd like to try one day, or did want to try when I wrote. If you attempt any of these I'd be interested in hearing from you! Email robert.meerman@gmail.com
As I frequently switch between the black-on-white default colour scheme, and my night-time friendly white-on-black, many programs fall short of the accessibility requirements this places on them.
For instance, Process Explorer uses some odd grey colour as it's foreground when the background of a line is coloured (“highlighted”), however it uses white-on-black perfectly for ordinary rows. If I could manipulate the default colour values it fetches from windows when it starts-up, I'd be able to over come this.
Similarly I ought to be able to over come similar problems in other software.
I'm an avid gamer, and would love to work in the industry; to that end I enjoy tinking with ideas and concepts on things which I'd like to see in a game. Among other things I proposed a Narrative Summary Engine for RPGs as my final year project, before encoutering resource problems (i.e. a game to work with).
The ultimate goal of which was to generate an informative and engaging summary of what you did last time (story-wise) in the game, akin to how television shows reel the audience back into the mood of the last cliffhanger with, say, “Previously, on 24”. Many RPG games are fairly linear in what must be done (though often leaving the player free to go about it as indirectly as they like), so it ought to be possible to compute what must be done next and what the last major event was, and hence produce a summary which also hints at what must be done.
If I were a Games Master in an MMORPG, I'd definately errect a massive, overly luxurious and imposing temple to honour myself, and be sure to make an absolutely massive statue of myself/avatar the main attraction. The mere players wishing to complain would involuntarily humble themselves before it before their complaint is heard. The intended effect being humourous, not arrogant.
Also, this incredible temple would lie on the otherside of a very unimpressive, rickety, ivy-covered wooden door with a very small sign which reads “Complaints Department”, probably buried in an alley of a busy city-centre.
Write some ActionScript to create impact animation, given the angle/direction of impact.
This ought to basically create the appearance of a ripple propagating through the graphic/movie. Use this effect multiple times on the same object, with different scaling to achieve (possibly) better results.
If you see errors like this:
Error detected while processing /home/robmee01/.vim/plugin/cscope_maps.vim: line 42: cs_read_prompt EOF: No such file or directory E609: Cscope error: cscope: cannot read trailer offset from file cscope.out Press ENTER or type command to continue
It's probably because the header in cscope database files (cscope.out) is space-delimited, and if the directory the database was created in contained spaces it won't parse correctly.
In Cygwin what cscope and bash think the current directory is may be different. In my case I saw this:
robmee01@e100325 ~/Projects/pixmap_test_win32 $ head -n1 cscope.out cscope 15 /cygdrive/c/Documents and Settings/robmee01/My Documents/Visual Studio 2005/Projects/pixmap_test_win32 -q 0000002403 0000137225
(Note that my home directory is not in Documents and Settings, but the default /home.)
I fixed this by replacing the path in cscope.out with an equivalent path that does not contain spaces (it doesn't seem possible to escape spaces…) and fixed-up the “trailer offset” at the end of the line.
See the cscope toolman page and look at the section on “Symbol Database Format”.
The trailer offset is a byte-offset relative to the beginning of the file. Therefore, if you change the path in the header and make your file 20 bytes shorter, than your trailer offset should be reduced by 20 as well.
Eventually I'll update my ~/cscope_gen.sh script, or recompile cscope to parse over backslash escapes in the header line…
I came to this solution after reading this post.
Win32 console's don't support ANSI properly, which is just plain annoying. In PERL you can overcome this with the package from bribes.org and then adding the following line to the top of a script:
use Win32::Console::ANSI;
'<,'>v/^|[^|]\+\%27v|/ s/\(^|[^|]\+\)|/\1 |/
To repeat this command numerous times, record executing it as a macro, then use normal macro repetition.
The break down is below, but the gist is that we find lines of text which don't have a “|” in the column we want, and then use a substition to grab the text before the second “|” and add a space between them, hence pushing the “|” one column to the right. You then repeat this command until no substitions take place.
'<,'> From mark "<" to mark ">" execute the following command
v/ --- / Check each line against Regular Expression "---", if it
**doesn't** match do the following commands
^|[^|]\+\%27v| Match a vertical bar, followed by 1-or-more "not vertical bar"
characters ( [^|]\+ ), followed by an assertion at we're in
visual column 27 ( \%27v ), followed by a vertical bar
s/ --- / ### / Substitute text matching RegExp "---" with text in "###"
\(^|[^|]\+\)| (Match) Capture between \( and \) a vertical bar followed by 1
or more not-vertical-bars. This capture should be immediately
followed by a vertical bar
\1 | (Replacement) Put our first captured group back, followed by a
space, followed by a vertical bar.
To use: source this into Vim (”:source <filename>”), and then invoke AlignTable() over the range of the table. EG Visually select table and then ”'<,'>call AlignTable()”
" Align a single ASCII-art table column
" tcol: Which column of the table to align (i.e. first column = 1, second = 2 etc)
" vcol: Align table column to which virtual/visual column on the screen?
function! AlignTableColumn ( tcol, vcol ) range
let i = a:vcol - a:tcol " Worst case
while i
" Edge one screen column closer to desired location
execute 'silent! ' . a:firstline . ',' . a:lastline . 'v/^\(\(|[^|]*\)\{' . a:tcol . '}\)\%' . a:vcol . 'v|/ s/^\(\(|[^|]*\)\{' . a:tcol . '}\)|/\1 |/'
let i -= 1
endwhile
endfunction
" Align a whole ASCII-art table
" Tables are expected to be drawn using "|" characters, including the header
"
" Usage: Invoke this function with the range of lines the table occupies,
" including the header - which will be used as the "desired column location"
"
" TODO: Tally the maximum width for each column by scanning all rows, and use
" these values to calculate new column boundry locations
function! AlignTable() range
let header = getline(a:firstline)
let bars = 0
let i = 0
" Count number of "|"s
while i < strlen(header)
if header[i] == '|'
let bars += 1
endif
let i += 1
endwhile
unlet i
unlet header
" Now get column widths for each row, keeping the maximum in colwidth
let colwidth = []
let i = bars
" Init list of correct length
while i
let colwidth += [0]
let i -= 1
endwhile
unlet i
let i = a:firstline
while i <= a:lastline
let row = getline(i)
let curbar = 0
let pos = 0
let poslist = []
while curbar < bars
let pos = match(row, '|', pos)
let poslist += [pos]
let pos += 1 " Move past current match, ready for next
if len(poslist) > 1
if colwidth[curbar] < ( poslist[curbar] - poslist[(curbar-1)] )
let colwidth[curbar] = ( poslist[curbar] - poslist[(curbar-1)] )
endif
endif
let curbar += 1
endwhile
let i += 1
endwhile
let poslist = [ match(getline(a:firstline), '|') ]
call remove(colwidth, 0) " Strip first column (always width 0)
for width in colwidth
let poslist += [ (poslist[(len(poslist)-1)] + width) ]
endfor
" NB There is one more bar than there are cols, and we ignore the first
" bar
let i = 1
call remove(poslist, 0)
for vcol in poslist
" Note that every bar must be moved at least once to avoid bugs, hence
" the (vcol+1) below
execute (a:firstline).",".a:lastline."call AlignTableColumn(".i.", ".(vcol+1).")"
let i += 1
endfor
endfunction