| Automating repository uploads |
[Aug. 31st, 2009|12:41 pm] |
A few of you may know I run an image repository which just grabs all links on IRC and puts them onto an archive. For those who don't, it's probably not safe for work, and lives at abhor.co.uk or disillusionment.co.uk for #compsoc only.
Anyway, I wanted to make it so I could upload images directly without too much hassle, and without storing an insecure SSH key (so I could in principle give the key to someone else).
Turns out it's pretty fun. I now even got it to support scp with multiple files. Here's an example:
[12:41:02] bucko(tank) ~$ scp test.jpg repo_up:
test.jpg 100% 110KB 110.3KB
Uploaded test.jpg (112971 bytes) Start with:
bucko@tank$ ssh-keygen -f ~bucko/.ssh/abhor_upload Make a 755 script abhor:~repo/bin/ssh_incoming_upload:
#!/bin/sh
if [ "$SSH_ORIGINAL_COMMAND" != "scp -t ." -a "$SSH_ORIGINAL_COMMAND" != "scp -d -t ." -a "$SSH_ORIGINAL_COMMAND" != "scp -r -t ." -a "$SSH_ORIGINAL_COMMAND" != "scp -r -d -t ." ]; then
printf "Can't login, noob. Command was: $SSH_ORIGINAL_COMMAND\r\n" >&2
exit
fi
cd /home/repo/incoming
printf '\000'
while read MODE SIZE NAME; do
case "$MODE" in
C*)
printf '\000'
MODE=C0644
SIZE16=$(echo $SIZE 16384 / p|dc)
SIZEREMAIN=$(echo $SIZE $SIZE16 16384 \* - p|dc)
FILENAME=$(basename $(tempfile .))
if dd of=$FILENAME count=$SIZE16 ibs=16K 2> /dev/null && dd of=$FILENAME oflag=append conv=notrunc count=$SIZEREMAIN ibs=1 2> /dev/null; then
echo "Uploaded $NAME ($SIZE bytes)" >&2
dd ibs=1 of=/dev/null count=1 2> /dev/null # null char
# Magic to queue the image into the archiver
printf '\000'
else
rm "$FILENAME"
printf '\002Failure!\n'
fi
;;
*) # Ignore D, E and T messages, as we don't care!
printf "\000"
;;
esac
done In abhor:~repo/.ssh/authorized_keys2:
no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="/home/repo/bin/ssh_incoming_upload" ssh-rsa KEYFINGERPRINTHERE bucko@tank In tank:~bucko/.ssh/config:
Host repo_up
HostName abhor.co.uk
User repo
IdentityFile ~/.ssh/abhor_upload And that's it! |
|
|
| When do people start uploading images from their cameras? |
[Jul. 6th, 2009|09:40 am] |
I noticed (well, I've known for years!) that my camera does not seem to reset its image number counter no matter what I do - change memory card, format card, send it in for repairs, and it seems like this is the norm.
So I got to thinking. When I first got it, I took a large number of "scrap" images, just playing with its settings. I wonder if that's normal? How many do people take?
Luckily, with the power of the web, we can attempt to find this out!
On a number of search engines, I searched for various (exp-distributed) searches of the form 'dscfNNNN', then tabulated the results. You can see the resulting graph below (Y axis is percent of maximum from each source).

As you can see, the prevailing opinion seems to be that the first 5 images are binned, at the most, with the majority of people scrapping relatively few initial photos. The speed with which the graph tails off also suggests that either not many people take many photos (ie. most cameras are just chucked in cupboard), that people sort their images more effectively, or that they just don't bother to upload as many once they get through their first memory stick. It may also suggest that some cameras do reset their counter, but then what causes the bulge at around 2-3 photos?
Both results from Google are odd in some way - the web one initially seems to fluctuate a lot, and the images one does it near the end. I presume for images the jump indicates that there's just a cap on the number which results in a second algorithm being used (crossover is at about 35). |
|
|
| Save the Planet competition |
[Jun. 5th, 2009|11:44 am] |
Inspired by a game which I saw mentioned in David Mond's Maths of Climate Change talk (actually, I read it rather than watched it), I've started a new competition. The aim is to save the planet!
Outline
There is a bot in #SaveThePlanet, on IRC server irc.uwcs.co.uk which listens for commands (rough protocol docs are available). It maintains a world state in which you have to, well, save the planet.
It's not always possible; you may be doomed. In fact, if you're playing against a number of evil entities intent on destroying the world, the world will be destroyed.
Climate badness is modeled by "chance of a disaster per tick", and is initially random. You can donate money per tick and hold industries. The more you donate, the better it is for the climate, and the more industry, the worse. The actual factors involved are picked at random per game, as is your initial industry count (more industry means more influence, but more likely to get disastered).
Should you save the world (read: restore climate to 0), the player who gained the most industry wins. Should you melt down the world, the player who donate the most wins. (See protocol document for specifics.)
Competition
The game will be running until the end of term. Each game will score points for the players who came out on top, and those points will be summed up over the day to produce a total. This orders the players for the day and gives points (6 for first place, 3 for second, 2 for third and 1 for fourth). Points are again aggregated over a week, and the weekly winners get prizes. Next week is a warmup (I'll use it to tweak the scoring and the game in general).
Each game, the bot picks between 2 and number of players asking to participate, and kills off the rest (players who've been in more games recently will be killed off more often) with no penalty, in order to give variation in the type of game you face.
The first competitive week runs from 00:00 Sat to 00:00 Sat over Week 9. The final week runs only until 00:00 Fri Week 10, to give me time to work out who won and present prizes at the CompSoc LAN. The final week will have £30 to the winner, £20 to runner up and £10 to third place. Prizes for the first week are undecided.
Sample code
Current version of the game bot is at: http://www.bucko.me.uk/competitions/SaveThePlanet/game.pl.txt
A sample bot (actually, 3), written in Perl, is at: http://www.bucko.me.uk/competitions/SaveThePlanet/sample.pl.txt (passwords are read from a separate file).
A Java sample using pIRCbot, is at: http://www.bucko.me.uk/competitions/SaveThePlanet/jarvur.
Win Data
You can get XML data about recent games:
Other stuff
I'll update this post as I tweak the algorithm until the start of the first week. The above code will be updated, too.
Prize is open to anyone I know and any member of CompSoc, plus anyone I feel like allowing to get the prize. If you wish to not be included in the prize giving, you can still compete, but let me know.
Good luck! |
|
|
| Core temperatures and Linux thermal cutout woes |
[May. 21st, 2009|09:01 am] |
Delightful. I've been encoding some DVDs recently, and twice I've left it going on one job and returned to find my system was off, after logging the following:
May 21 06:14:35 tank kernel: [24200.843888] ACPI: Critical trip point
May 21 06:14:35 tank kernel: [24200.843888] ACPI: Unable to turn cooling device [ffff8101af06f8b0] 'on'
May 21 06:14:35 tank shutdown[27159]: shutting down for system halt
May 21 07:51:14 tank syslogd 1.5.0#5: restart.
The second time, the encode jobs appeared to have finished (I had a valid and complete AVI file), yet the system still cut out. They were simultaneous and of different lengths, so they would have finished at different times.
Further, I've been checking on sensors - the ACPI thermal_zone temperature at /proc/acpi/thermal_zone/THRM/temperature reports the same value as the w83627ehf device - specifically, 22C at idle, maybe 55C max at load. This seems pretty normal to me. The core temperatures are more worrying, at 45C idle, 82C load.
I've got a stock HSF on an E6600 at default clock. When at load, I've also got a noisy 120mm fan pointing directly at the HSF with the case open.
Are these numbers normal? If so, what's going on? Internet won't even tell me normal coretemp numbers... |
|
|
| Banks and Passwords |
[May. 12th, 2009|05:47 pm] |
Some people probably know I'm going through a password reset period right now. Included in this is my banking passwords for NatWest, Alliance and Leicester and Egg.
I have made some worrying observations to this end. Firstly, NatWest and Egg (at the least) ask for individual characters on login. This practice reduces the user's ability to add security by pre/app-ending a long known phrase to their password as an unguessable salt, but on the plus side makes it harder to keylog a password. More worrying, however, is the following bizarre password policies employed by the banks:
| Alliance and Leicester | - 8 digit customer number, unchangeable.
- 5 digit PIN for login (cannot be a consecutive run or constant digit).
|
| Egg (Banking) | - Address and DOB.
-
Mother's Maiden Name (changeable by calling them, I think - but displayed and read verbatim in phone conversations).
-
Password (5-12 alphanumeric chars. No further restrictions. Even 'aaaaa' was valid...).
|
| Egg (SecureCode) | - Username (login via egg), or
-
Various card details (login via seller).
-
Password (5-18 characters alphanumeric, at least 2 numbers and 1 letter. Can't re-use old password.).
|
| NatWest | - Customer number (10 digits, unchangeable).
- 4 digit PIN (3 random digits asked for on logon).
- Password (3 random chars asked on logon; 6-20 alphanum, at least one numeral/letter).
|
As you can see, there's some fairly arbitrary restrictions here. Why aren't I allowed to use symbols? Why does 2 digits and one letter make a password secure (considering, say, may12, meets this criteria)?
Do any banks let you use hardcore passwords? It'd be great if people could play around and let me know various banks' policies on passwords. |
|
|
| Anki passwords |
[Apr. 29th, 2009|11:42 am] |
So I was pointed by Sadiq Jaffer to Anki, a spaced learning flashcard application. One of my first thoughts was that this would be a pretty useful tool to learn passwords, except that a) they can't be put into your shared deck (or you'll end up displaying them in public), and b) it would mean storing all of your passwords in plain text.
Well, no longer. I wrestled with the pain of Python, PyMe, hashlib, unicode and reading the somewhat undocumented Anki source (it seems 'plugin' is more akin to 'hack', so I guess it'll break on later versions) to create a password tester for Anki.
All data is stored in either UTF-8 GPG-encrypted (for displaying) or SHA1-summed Base64 encoded UTF-8 encoded (don't ask) salted strings (for just testing you), so someone getting ahold of your cards needn't be a concern. I don't know how secure the actual interface is against memory checkers - but if you're worried about that, don't type the buggers in. :)
Anyway, you can get the plugin from Anki's online plugin browser or http://www.bucko.me.uk/software/passwords-anki.py.txt - it probably only works with the latest version. It's GPL3, since Anki is, too. |
|
|
| Twitter |
[Apr. 27th, 2009|03:18 pm] |
I'm sick of it, guys. Every time someone posts a link to a Twitter user page or search I feel like someone's vomited the encoded Matrix all over my browser. I'm no operator; I can't read this shit.
Twitter provides me no link to explain what the hell I'm seeing. Its frontpage tells me very little information ("Twitter is a microblog" in a few more words), and only invites me to join.
All of my interpretation was inferred by playing around a bit or using Google and finding answers on people's blogs. Thank you, internet. Some of it, I found on Twitter's help site which is notably not linked from any main Twitter page I could find. I'm posting it partly just to illustrate just how much stuff on their pages is utter nonsense to a non-Twit.
I expect there's a billion other bits textual offal that you get when you can be bothered to read a few hundred pages of this. For example apparently "RT" means you just copy/pasted someone else's entry — something which the search page (from just below where I cut) suggests makes up a notable percentage of content on this monstrosity.
 |
|
|
| Using xvfb and xte to automate bulk use of non-free software |
[Jan. 24th, 2009|11:44 pm] |
I frequently have to send messages to large numbers of people, namely the leaders of clans on the KGS Clans System. This is tedious work as the client has an awful non-keyboard navigable UI. In fact, the minimal path to send a message turns out to be:
- Start CGoban
- Send space to press the default activated logiin button (return doesn't work).
- Press return twice to log in with saved user/pass.
- Wait for the rooms box to pop up.
- Click the menu bar (can't use a keyboard shortcut...).
- Navigate to the User menu. Press up to get to "leave message".
- Press tab, as it defaults to having no widget in focus.
- Type the target user.
- Press tab or return.
- Type the message.
- As you are now unable to keyboard-navigate from the input box, click "OK".
I dread to think how the author would respond were some poor disabled person to explain how painful it is to operate that monster.
Today I coded a hack/fix for this problem. I have a shell script which automates this process using xvfb, xwininfo and xte. It is now fully integrated into my admin system so that I can message various groups of clan leaders.
Java is slow, meaning there are frequent "sleep" calls to ensure things happen. Also, xte does not seem to enjoy the company of xvfb. Specifically, "key colon" produces a semicolon unless surrounded by "keydown Shift_L" and "keyup Shift_L". This happens with capital letters and many other symbols. Additionally, "key :" works on my X server but apparently not on xvfb, and "str :" works locally but gives an X error on the remote. I am unsure as to how to fix the xte problem, and have left a kludge in the script to use Perl to manipulate a string into something it'll like. It only accepts a small number of symbols. |
|
|
| Golf Results |
[Jan. 6th, 2009|12:52 am] |
A humongous 2 entries to this one. There was a clear winner:
Zed0
Perl, filename must be '278951438'.
sub p{print 1+int$_/3,-1-$_%3;die}@_=map{(/O/?99:/X/?1:-1)*chop$0}split/\n?/,<>.<>.<>;map{$a=@_[$_];map{$b=@_[$_];$a*$b<0|$a+$b-@_[$_]-15||p for@z}0..$_-1}@z=0..8;@_[$_]<0&&p for@z
I can't pretend to understand what it does, but it does pass all of my tests. Total length is 181. I'm informed that the filename is a magic square which is solved to find possible lines.
Rupert Swarbrick
Once again attempting to golf in a non-golfable language. This one (factor) has compulsory whitespace, compulsory non-evaluation brackets, but at least no nasty angle brackets for me to quote in my HTML.
USING: arrays kernel math combinators io sequences namespaces assocs prettyprint ;
IN: A SYMBOL: z
: s swap ;
: a 32 s index ;
: b [ 1 + ] bi@ z get { { 1 [ s ] } { 2 [ dup rot 1 = [ ] [ 4 s - s ] if ] } [ drop ] } case "," s pprint write . ;
input-stream get lines dup dup [ flip ] [ dup reverse [ [ s ?nth ] map-index ] bi@ 2array ] bi 3array >alist [ first2 s z set [ [ [ 88 = ] count 2 = ] [ a ] bi and ] find a dup [ b t ] [ drop ] if ] find [ 2drop ] [ drop 0 z set [ a ] find [ a b ] [ 2drop ] if* ] if
Total length: 517 bytes. It's over half a kibibyte! Rupert has outdone himself on this one.
More amusingly, his co-ordinates are backwards, meaning it fails half of the tests if I don't reverse them. :)
I think Rupert's aiming for the "points for participation" award, perhaps... |
|
|
| O2 Mobile Broadband first thoughts |
[Dec. 9th, 2008|09:39 pm] |
So, today I nipped into town and got myself some mobile broadband. I went with O2, as their PaYG package is basically the same as most contracts (with shorter period options - £2 for a day or £7.50 for a week) -- with no minimal period, and you only pay for it it you want to use it! Of course, you have to spend £30 on the modem, but that's not such a hard hit to take.
Let's get the plus out of the way: When it's connected properly, it works. It's fast, it doesn't seem to drop out (yet); it just works.
Now, the software it comes with is atrocious. It hangs for a minute every time you connect or disconnect. It minimises to tray, and can't be told not to. It's a skinned region window. It often gives little feedback about what it's up to. And finally, they committed the ultimate crime: They didn't use a standard interface to do a standard thing. It's hardly common to O2; my dad's got a dongle, too, and it uses some godawful software with similar problems. Seriously, XP/Vista provide a dialup service; why can't you use it?
Coverage seems somewhat iffy. I played with it a few times on the train to Edinburgh, and found it often would get a signal, but refuse to connect to it (including when stationary in a station). It worked fine both at home and in my guest house room.
I also seem to be connected through some transparent proxy on crack. It's chopping off some of the end of HTML documents, resulting in XHTML parse errors from Opera. Refreshing the pages in question always makes it work fine - it seems like it only does it on the first page view of a page, and in the case of my image repository, always immediately after the "http:" of an URL (original: '<a href="http://blah">http://blah</a>(moreHTML)'; O2: '<a href="http://blah">http:</body>(newline)</html>(endofdoc)'). The worrying thing is that it's not a 100% chop; it's still giving a </body> and a </html> - it's not closing anything else, though.
Summary, so far: It's pretty OK, but I think I'm glad I'm on PaYG. |
|
|
| Golf results |
[Nov. 2nd, 2008|11:59 pm] |
Results are in for the rational numbers golf!
David Bewick
Entry in Perl, command line perl -Mbigint dbewick-entry:
$n=<>,$d=<>;map{$d/=$_ while$d%$_<1}2,5,$n>1?$n:2;7while$n%$d>0&10**++$_%$d>1;print
Score is 7 + 84 = 91. I have to say, I'm impressed by the optimisation here (ie. I don't understand it!). The code appears to first eliminate the terminating expansions and then compute expansion length. At first I thought I could shave some score with few quick modifications (use perl -p change $n=<>,$d=<> to $n=$_,$d=<>;$_=0), but alas it's score-neutral. Of the submitted solutions, this is the shortest, so is the winner.
whythehell
Entry in False (interpreter at http://wouter.fov120.com/files/lang/false/False12b.zip or http://kahneman.dyndns.org/ -- commandline false_int filename.f $a $b):
b;c;[$@$@/@*-]m:$[$1=~][[2O1Om;!2O2Om;!+0=][@1O/@2O/@]#1-]#@@[\[$2Om;!0=][1O/]#\%]$@5@!2@!1$[10*2Om;!$1>][\1+\]#%.
Score is 115, and I won't pretend to know how it works. Interestingly (and quite annoyingly for wth), False does not have a remainder operator, which is what he implemented in the first square-bracketted section. I presume the code first eliminates the terminating expansion case, then computes the length by long division.
The code has the drawback that the interpreter spams its interpreter message on every run - and since the stack is nonempty on exit, spams an error also. Both of these are on STDOUT and thus break the spec. Appending 3 % signs removes the error at the cost of 3 extra points (118 total). The former is an interpreter issue, so is forgiven.
Michael Tandy
Entry in Perl (commandline only; parameters at end of commandline):
perl -e 'sub L{($a,$b)=@_;$g=$a;for($i=1;$i<10000;$i++$g=($g*10)%$b;if($g==0)return 1;}if($g==$a%$b){return $i;}}return L($g,$b);}print L($ARGV[0],$ARGV[1]);'
1 command line bit, 149 chars in the quotes makes a score of 150. The code doesn't work, but a slight modification does:
sub L{($a,$b)=@_;$g=$a;for($i=1;$i<10000;$i++){$g=($g*10)%$b;return 1 if($g==0);if($g==$a%$b){return $i;}}return L($g,$b);}print L($ARGV[0],$ARGV[1]);
(A score of 152 including the -e). The code executes corrently on my test data set of (1, 2), (2, 7) and (7, 7). Further analysis of Michael's code reveals it will fail to terminate when fed (1, 10007), due to the odd looking recursion. Removing the central test in the for() and the recursive execution fixes this bug - and shortens the code! Using this and some other simple changes the code can be reduced to correctly executing code with a score of 107.
Rupert Swarbrick
Entry in postscript (command line echo "$a $b" | gs -dBATCH -q entry.ps):
(%stdin) run /a{{dup 3 2 roll dup 4 3 roll mod 0 eq{exch dup 3 1 roll idiv exch}exit}ifelse}loop exch pop}def /d{dup 3 2 roll dup 4 1 roll}def d d ge{exch}if pop 2 1 3 2 roll{{3 1 roll d 5 4 roll dup dup 7 1 roll 4 1 roll mod 3 1 roll exch mod add 0 eq{3 2 roll dup dup 5 4 roll exch idiv 4 2 roll idiv 3 2 roll}{3 2 roll pop exit}ifelse}loop}for exch pop 2 a 5 a dup 1 le{pop 1}{dup 1 10 4 3 roll mod{dup 1 eq{pop exch pop exit}{10 mul exch 1 add exch 3 2 roll dup 4 1 roll mod}ifelse}loop}ifelse stack
504 bytes of source, plus 7 characters in the commandline, so a score of 511. At least it was under half a kibipoint! As this submission was not near winning, I will forgive the transgression of requiring the input to have no newlines. The code appears to work on a random variety of examples. It was apparently written non-golfed and then had some disgusting emacs function reduce it to a shorter example. I'd give negative marks for not using vim, but I only have his word for it. The code removes all 2 and 5 divisors, and then finds the multiplicative order of a, mod b.
David Buckley
Entry in dc, the GNU reverse polish calculator (input on stdin; commandline dc entry.dc):
??dsb[r10*lb%r1-d0<g]dsgx+dsa[d10*lb%dla=dd0=flex]dse[zd1-nQ]sd[1nzQ]sfx
73 bytes source, commandline comes free, so score of 73. Yeah, I know, entering my own competition, I couldn't resist giving the entries a good thrashing! In pseudocode, sets $c to $a, then repeatedly does $c = ($c * 10) mod $b, firstly $b times, putting the result in $a, then until the result is either 0 or $a. In the former case, outputs 1, in the latter case outputs the number of iterations, which it tracks using the stack size (it leaks into the stack deliberately). It's probably improvable, but it's still a good quick effort.
Edit: Seems I made a bad assumption - my original code will only reliably compute 1 / b. Thanks, DBewick. Code updated to take this into account.
Watch this space for a new competition soon. |
|
|
| New golf |
[Oct. 21st, 2008|12:19 pm] |
The Problem
A little simpler than the last one. Given two positive integers a and b, it is well known that there exists a decimal expansion for a÷b. For example, 17÷3 = 5.6666666666666666…. Any terminating expansion is assumed to have an infinite number of trailing zeros. Your task is to compute for any two inputs a and b the length of the repeating part of the decimal expansion. We will call this l(a, b).
To illustrate further, l(17, 3) = 1, l(3, 1) = 1 and l(1, 99) = 2.
Implementation
Your code will be run with decimal encodings of a and b seperated by newlines on standard input, or a then b as the first two command line parameters, or both (please specify or I'll assume the latter. That is: $ (echo $a; echo $b)|$yourcommandline or $ $yourcommandline $a $b or $ (echo $a; echo $b)|$yourcommandline $a $b
Your code should output l(a, b), as a decimal number, on standard output. It may also output a single newline ("\n", "\r" or "\r\n" but no others) after this. No other output is allowed.
As input lengths are often a problem, a will be between 1 and 93744, and b will be between 1 and 75283. Your code need not behave correctly with inputs outside of these ranges, but must behave correctly inside them.
Submission
Your submission should contain: Firstly a source file (optional if you are using perl -e or similar), and secondly a command line with which to run the source file. This will replace $yourcommandline in the example above. It may also contain any number of extra files which your code needs to run.
Completed entries should be sent to: progcomp20081021@bucko.me.uk by the end of Sun 2 Nov 2008 (BST). Multiple submissions are allowed (and encouraged if they're in different languages/different algorithms).
Scoring
I apologise for this section being long, but some people always try to abuse missing clarifications.
Your score will be the total length of your code. This is the character length of your command line, plus the character length of all of your filenames, plus the byte length of all of your files. Certain things are available for free:
The command line may consist of the name of an executable on my Debian GNU/Linux system and your source file name (which I may alter, so don't try to cheat by encoding your solution into the file name) for free. It may also contain any number of switches to the executable, of which the switch symbol ("-", "--" or "/") is always free, but switches must always contain at least one character other than the switch symbol. There may only be one command on your commandline. If you want pipes etc., you must use a soure file. Your source file name is also free.
You may submit compiled code with source, provided it will compile on my Debian GNU/Linux system. In this case, your source length is deemed to be the smaller of my compiled executable and your source file, and the compiled executable's filename is free. The length of your compiler command line is added to the length of your execution command line (though the latter will probably be zero), and is scored in the same way.
For example, suppose that Jack Jones submits the command line perl -wp progcomp.pl The answer is and source file progcomp.pl with content use warnings; print "@ARGV[0..2] 4";. Besides the fact that his submission does not count, since he failed to solve the problem, his command line is free except for "wp", "The", "answer" and "is" (total length 13), his source file name is free, and his code length is 36. His score is thus 49. The parts which cost are underlined to better illustrate.
If multiple entries of a similar nature (same algorithm or same language, etc.) are recieved, they will be grouped as such when scored, so that there may be multiple 'category' winners. There will also be a winner for shortest overall code.
In the event of a tie, the lowest number of alphanumeric characters will break the tie. If this ties also, similar tiebreaks will be invented until one of them breaks the tie.
Hints
Hints at http://www.bucko.me.uk/progcomp_hints.html, for if you get stuck on how to implement the problem. But please have a go at figuring it out before you read them.
Edit: Clarified the means your application will recieve input. |
|
|
| Golf results. |
[Oct. 1st, 2008|12:12 am] |
A total of 4 people entered.
Michael Tandy Winner on the golf front (and not on the following the rules front), and has a definition of "game" so loose that I seriously worry about his childhood. Here's his winning entry (37 characters) with name "Guess N, 0<N<99 short":
$ perl -lpe'$s--;$_.=$_>4?">N":$_<4?"<N":die$s' Of course, since he could have used a filename for free, it can be trivially reduced to 36 characters as follows:
$ echo '$s--;$_.=$_>4?">N":$_<4?"<N":die$s' > 'Guess N, 0<N<99 short'
$ perl -lp 'Guess N, 0<N<<9 short' He also sumbitted a 60 character version which is slightly harder ("Guess N, 0<N<99 crashes"):
perl -lpe'BEGIN{$s=6}1/$s--;$_.=$_>34?">N":$_<34?"<N":die"score $s"'Finally, apparently misunderstanding the purpose of golf, he submitted a verbose solution at 75 characters ("Guess N, 0<N<99 verbose"):
perl -lpe'BEGIN{print"Guess N,0<N<99"}$s--;$_.=$_>34?">N":$_<34?"<N":die"score $s"' Of course, all three games fail the "3 or more common scores" criteria.
I think I preferred playing Big Rigs: Over the Road Racing.
Faux Winner if you believe in "following the rules", since I apparently didn't specify that I had to be able to run the game in my chroot, only compile it (which I can theoretically do, I expect, but his entry just hung in dosbox). I did succeed in running it on my 32 bit Vista, though. Weighing in at 46 bytes with name "HighOrLowGuess0-9", his entry is written in 16 bit assembler. The game plays fairly easily once you press a key from 0-9. It allegedly compiles under the a86 assembler (no debian package that I could see, so I'll just believe him, or assume he wrote the binary raw or something).
whythehell At first, I assumed his code could run on the command line; the "just make it executable and it'll run" finally hinted to me that his code was meant to be run by saving it to a file. I also needed to install the 'wbritish' package to give look an input words file. Ooops. Entry name is "TypLngWords4PtsUseEntr", length is 56 bytes, file content should be:
sed 's,.*,look &|grep ^&$,e;:;s,.,,p;t'|wc -c&sleep<&-10 Cudos for coming up with a definitely original concept, and also for getting sed to output a read error after the game finishes. Interesting features of this game are that it gives points for trying (even incorrect words give one point - and even blank ones, though you get an error from look when you try that), and if you haven't started typing a new word after the time runs out, you're dropped to a prompt and get your score when you press any key.
mulletron Having submitted not only the worst game, but also the longest one, including Michael's "verbose" solution, mulletron clearly has a super idea of fun. Instructions were provided to install a haskell interpreter (apt-get install ghc6), and allegedly the entry can be run runhaskell Progcomp.hs, at 91 bytes:
import System.Posix.User
main=getLoginName>>= \x->putStrLn$x++", You just lost the game!" I think I must have won, though, as:
$ runhaskell Progcomp.hs
Progcomp.hs: getLoginName: invalid argument (Bad file descriptor) If only I understood what any of that meant. |
|
|
| Installing Debian on P5QL motherboard |
[Sep. 25th, 2008|12:43 am] |
Debian Etch currently does not (and presumably never will) install on an ASUS P5QL Pro motherboard, and presumably related boards. I have succeeded in getting an AMD64 install in the following way (warning; kludge to follow):
- Spend ages tweaking an AMD64 chroot install on a partition using your existing AMD64 machine. I did this since I didn't yet have the board and wanted something to do.
- Fail to boot the system using this.
- Turn on AHCI disk access in the BIOS.
- Obtain an Ubuntu 7.04 i386 Alternative DVD (apparently the graphical one broke with my card).
- dpkg --force-architecture --install the deb for the latest (2.6.27-5 at time or writing) AMD64 kernel
- Use grub to boot your chroot with the initrd and kernel above, with init=/bin/sh as a boot option.
- From the prompt, chroot into your new system, and install the kernel packages (actually, if you weren't as stupid as me, you might have done this first).
- Boot properly into this new system, copy the config-whatever file to the source for the newest kernel from kernel.org, and make-kpkg, install the deb, etc. (the Ubuntu one needed a mewer libc6 than in Lenny)
Of course, most of this wasn't required in hindsight. Key points, though:
- You need 2.6.27 (maybe 26) for the atl1e driver for your network card. My suggestion is to use a chroot system like I did, but do it properly first time. Note that the driver supplied on-CD compiled fine under Ubuntu, so if you can get your system installed by other means, you may be OK.
- You need to set AHCI disk access in the BIOS, or nothing works (more specifically, generic.all_generic_ide was the only way to get things recognised, and I got random hangs while transferring data; I may have needed irqpoll, too...).
Sound card is hda-intel and works fine, contrary to linux-tested's opinion. They admittedly were probably using older kernels and different distributions.
PATA support is pretty dodgy; my CDROM drive seems to think it's got no media in often when I mount it (but I've successfully mounted it a few times under Ubuntu at least, to install packages); ejecting works fine. Eventually gave up and just bought a SATA CDROM, ridding myself of IDE forever.
Following the advice from Alf Høgemark and using modprobe w83627ehf force_id=0x8860 resulted in working sensors. |
|
|
| Setting up a local Debian install which will be remote |
[Sep. 22nd, 2008|04:09 pm] |
Having just purchased upgrade components for our house's media machine, and having an ostensibly spare (read: had more unpartitioned space on main drive than this drive had total) hard drive in my main machine, I decided to pre-install a Debian.
Downloaded a netinst AMD64 ISO and used it as a -cdrom in qemu with no acceleration with main HD in qemu as the target drive (I was too lazy to install kqemu, and too lazy to find out how to make kvm work with AMD64 guests, if it works at all; qemu just had qemu-system-amd64. Of course, I was probably just being stupid and could have run straight KVM.). OK so far. Install went smoothly (if incredibly slowly; took over half an hour to get to tasksel, which I selected nothing in...) until...
Installing GRUB to the drive. I killed grub-install after 20 minutes of boredom. OK, no real loss, I was going to do everything in a chroot anyway. GRUB was angry in the chroot too, though, and wouldn't see any BIOS drives even with /dev, /sys and /proc visible from the main system. This mad it a PITA for me to bootstrap (see other the problems with P5QL post).
Installing the nvidia drivers was made insteresting for two reasons - first because the target kernel is my own build due to driver issues, secondly because nvidia-installer (needed to build for newer kernel) was disgusted by my chroot. Eventually I made a stub lsmod and stuck it in my $PATH, then run sh NVIDIA-whatever.run -k kernel .
tasksel hung running aptitude when I tried to install the Desktop task, but I could install it manually from aptitude. I had to temporarily diable the running of fam to make famd install.
Barring some successful package installs, this was as far as I got before I started on the install as a 'live' setup. |
|
|
| An awesome tool |
[Sep. 20th, 2008|03:34 pm] |
I often find myself copying masses of data in a tree structure which is highly irregular (for example, a backup of an entire disk), and for which some stuff I really don't care about.
I want a copy utility which has a button labelled "I don't care about this shit" (it might be ^C for console), which I can hit, select some point further up the tree and have DFS drop back to that level and continue. This means, for instance, I can avoid copying an entire texmf install in my Program Files, but still copy some cheap games for which I lost the installers. It might want to have an option to erase the partial tree while it's at it.
This sort of thing is only really known once the copy begins, as there's no way I'm going to dig through my tree and find I've got a billion log files from some server software that are taking ages before I run the copy. |
|
|
| Golf! |
[Sep. 16th, 2008|02:11 am] |
So, I finally thought of a programming related participation post. Of course, since it's me, it's a golf.
TaskYour task, should you choose to accept it, is to produce a short program which could be considered a game. This might be a real-time strategy game, a full-featured 3-D shooter with 64 bit environmental sound and ragdoll physics, or just a simple maths game - but remember that you might want to avoid features as much as you can, since the aim is to produce a /shortest/ program.
I define a game to be any program which takes some form of user input, requires skill on the part of the user, and can be played either head to head against one or more opponent, or gives the user a score rating their performance. If it is head to head, a game should ensure draws are reasonably unlikely. If it is score based, a perfect score should either not exist, or be very hard to attain, and there should be more than 3 common scores.
Unless you have a good excuse, a game must last at least 10 seconds and in that time require at least 2 decisions/inputs from the user, and a user who understands the game (has read the readme, and played a few successful attempts) should be able to complete an attempt at the game within a minute or so of starting it.
SubmissionsYou are allowed to use any language I can reasonably get to work on my Debian GNU/Linux AMD64 system. You must submit source code, but may use the compiled code as the benchmark on size - if you do, you must specify exactly how I can reproduce the small binary. All code will be run in a chroot, and if you need a 32-bit environment or Debian unstable, I can build a chroot for that, too. You may also submit an executable which I will be unable to compile myself (for example, a Windows .exe file), but I must be able to run it without too much trouble (in the windows case, must run in stock WINE on some Debian chroot I can manufacture), and again have complete instructions to reproduce your binary.
JudgingFor scripting languages, the length of any command line options (you're allowed any leading hyphens to command line options for free, though) will be added to your code length, so for instance, echo 'print "You win!\n"'|perl -w has a length of 19. For compiling source, the complete length of your build script will be added to the source length to get the total. Binaries will simply be taken to be the size of the binary. Any additional data files will have their size in bytes and filename length added to your total.
Additionally, the name of your game will be added to your code length (the first 23 characters are free). If your game has any features, keybinds or gameplay which are not implicit from its name, you must include a readme.txt whose contents will be added to your code length. I anticipate that this will be needed in most games, though it may be very, very brief in some cases.
Reasonable libraries and required applications (read: Debian packages, and anything I can compile trivially) can be used for free. Unreasonable libraries (read: A library you wrote which includes everything but your main function) will have their code length computed as above and added to your own.
You're allowed a single free pipe of stderr or stdout to /dev/null to make your game playable. Additionally, each unique (in the sense of an instance in your code) warning will reduce your total code length by one. Bonus marks for a crashing your language if the player loses.
As well as shortest length overall, awards will be given to any games which include a lot of innovation in a small space (for example, a 3-D engine or network play), and especially to any which have varied gameplay or are actually fun. If two or more games fit any class I can think of, or are in the same language, awards will be given for the shortest in that class/language.
SubmissionsEntries should be submitted to progcomp20081001@bucko.me.uk and you have until 23:59:59, Sep 30 to get your entry to me. By submitting, you're allowing me to reproduce your code, code's output and anything reasonably related, perhaps with commentary, as I see fit to make the results page, and any redesigns thereof.
Edit 1: Added bonus marks for breaking languages, and put a rough cap on playtime so that no impossible games are produced. Also required that gameplay is at least a bit varied by mandating >3 common scores. |
|
|
| Online media sales |
[Sep. 12th, 2008|10:38 am] |
I'm slowly coming to the realisation that mainstream media is finally waking up to the fact that traditional media sales are going to collapse any year now and are taking ventures into online sales. Not only that, but a lot of them are realising that DRM isn't the greatest of marketing tools.
At this late stage of the game (I've been able to download DivX movies for about 8 years or more, now, and MP3s for longer), let's look at a brief survey of the offerings, and compare them to traditional media and the illegal filesharing alternative.
Music
I'm currently registered with eMusic, which is a subscription service offering medium quality DRM-free MP3 downloads. They are VBR and average around 190kbps (their FAQ explains that it's VBR 192kpbs, presumably stretched over an album). The cost per track is about 25-30p, so for an album with around 13 tracks, which seems to be the average, it will cost around £4 at the most. You can download for as long as you keep paying your subscription.
Amazon.com have MP3 sales also, although the media companies handing out the contract (or perhaps Amazon itself?) have for some reason seen fit to allow only US customers to purchase the music. The selection is reasonable. Songs cost $0.99, and the cost per album is anywhere between about $5 to $10, and anywhere between 1/3 and 9/10 of the album price; I suspect there's a standard formula relating # tracks to cost per album. This works out at around £3 to £6 per album at the current exchange rate. US physical albums seem to be no more expensive than $16, which is about £9. Amazon explains in its FAQ that its MP3s are 256kbps. They don't appear to allow repeat downloads.
By far the most popular, and largest online purchasing system (who knows why?) is iTunes from Uncle Steve. The only information I seem to be able to find without downloading iTunes is the (typical?) cost per song and per album and a rough guide as to "has this artist" using the online search facility. Their own FAQ suggests they only offer DRM-locked 128kbit AAC (equivalent of 160kbit MP3) downloads. Songs on iTunes cost £0.79, according to their site, which may or may not include the premium for 256kbps DRM-free songs ($0.30 in the US). Albums cost £7.99, and apparently DRM-free ones normally cost the same. While it appears that the store keeps track of your purchases (you can "upgrade" albums to DRM-free at a price), they do not allow repeat downloads.
Finally there's Napster which is effectively two sites, as it offers DRM WMA subscriptions and DRM-free MP3 downloads. Their website offers apparently no information and refuses to let me in with Opera/Linux. Apparently the cost per download is £0.99 per track, or £0.79 if you're paying the £10/mo sbscription, and per album is £9.99 or £7.95 under subscription. You can get 128kbit or 256 kbit MP3s, and the selection is reasonable. They have a link to "download again", which presumably means you can.
I know of no other (legal) popular purchasing sites for MP3s, so let's go onto physical media. They contain 1.1Mbit raw audio. New recent albums cost around £10-£12, and older ones drop to around £5 within a few years. Second hand albums from Amazon marketplace/Playtrade come in at typically £3. Excepting copy protection (which I've never noticably encountered under Linux), these are DRM-free and better quality than any of the above.
Finally, copying. Most recent albums and a lot of older ones have active torrents, and obviously cost nothing, and increasingly the torrents are lossless, putting them on par with CDs. They're free (obviously), and DRM-free.
In summary, music downloads are now almost all DRM-free, and almost all cheaper than new, recent albums. Once an album gets a few years old, CDs seem to be both higher quality and cheaper. It seems like the market for one or the other of these will need to change. Additionally, the online stores are continuing to offer lower quality downloads than the illegal copiers.
Movies
There aren't too many services in this category. iTunes charges roughly the same as a new DVD for FairPlay DRM at (according to various non-Apple sources) 640x480, 1.5Mbit h.264 (about 1Gb per DVD?). I don't have any comparison between this and DVD quality, but I certainly notice artifacting at 3Mbit h.264 with my naive encoding techniques.
Neither CinemaNow nor ReelTime could find any specific movie I searched for. Both employ DRM and it's difficult to ascertain the resolution, bitrate or price for large movies when I can't find any.
The only other worldwide one I can find is ZML, which doesn't have pricing for its videos without signing up, but very clearly states resolution and format. It's normally fairly low res DivX at about 1Mbit, however they are allegedly significantly cheaper than DVDs.
For physical purchase, we have DVDs, which weigh in at anything from £3 for an older movie to £13 for a recent, popular one. Second hand DVDs can again be had for smaller prices. Blu-Ray typically comes with, roughly, a £3 premium. Blu-Ray will be crushingly good compared to any online store, and DVD probably also betters them. DVD is basically DRM free, though the user must have fun with telecine transforms and DVD CSS encryption to be able to play on any device. Blu-Ray is heavily DRM-ed, although it appears volume keys for most releases are known, meaning it's at least possible to decrypt them.
For illegal copying, it seems most movies are available in DivX at around a gigabyte, and many seem to be available in H.264 encodes are much higher sizes - for instance, Star Wars is available at 5GB per episode. On the whole, though, DVDs seem to win in quality over illegal copying.
Anime
As far as I'm aware, there are only two services offering online purchase of anime. Probably this is caused by the massive amount of copying that happens with anime. Both over DRM free content. Crunchy Roll offers 350MB DivX encodes (with noticable artifacting) and BOST TV offers smaller, but higher quality as best as I can tell, H.264 downloads. Both are hard subtitle (overlay, then encode) only, lower resolution than the filesharing alternative and cost around $3 per episode.
Physical media typically costs around $40 for a 13 episode series. There's a strong correlation there.
Games
Being the most automatically digital content of them all, games have been DRM infested for a long time. The only download service I've used is Steam, which offers identical content for normally slightly cheaper prices. You can download as many times as you like, install on as many machines as you like, and the only restriction is that you can only be online with your Steam account on one machine at a time. It even runs in WINE. That's pretty non-draconian compared to some of the above attempts.
Of course, copied games frequently allow even this to be removed. However, Steam is good enough that it really genuinely does compete. I champion the games industry (or just Steam) as being far and above the most sensible. However, they have the advantage of only needing to allow their content on internet-connected PCs (since everyone who games has them). Notably, what gets me to buy games on steam is ease of access, not price or their DRM.
In Summary
So, the industries are trying. But they really don't seem to be embracing online content at all - all of the services (bar games) offer content at slightly or significantly lower quality than the physical media alternatives, normally a not incomparible price (except for some cheaper but lower quality services) and in the movie case, also less universality due to the DRM. In almost all cases, they are not offering anything better than the filesharers.
Given I can already download, for free, better quality stuff than they're trying to sell, I'm not sure where they derive their strategy from. They're hardly denying the copiers a source to copy, and they're hardly offering an incentive other than the "moral" or "fear" ones. |
|
|
| Gigabytes. |
[Sep. 6th, 2008|01:49 am] |
Billions of a unit is just too much. Gigabytes should now be referred to as cubic kilobytes.
That is all. |
|
|
| DDoS attacks - why do they work? |
[Jul. 23rd, 2008|04:57 pm] |
So, 4chan is under a massive DDoS attack right now, causing it to be completely inaccessible. This doesn't exactly bother me as I rarely use it. But it does bring me to wonder: How can such an attack persist?
DDoS attacks are a result of many small internetted machines sending large amounts of data to the target until it crumbles. This data presumably gets routed through a number of routers: The breached computer's ISP, their upstream, large hubs, the victim's upstream, the victim's ISP and finally the victim.
Obviously when this sort of thing happens there's a block at the recieving end, presumably as far up as they can go to save the costs of recieving all the spam. My question is why can't the blocks happen at the sending end?
DDoS attacks must be readily recognisable with minimal inspection. It seems most routers nowadays use connection tracking and it's pretty unlikely anything can make a connection to the target under all this abuse, so one is led to suspect that all this data is sent via SYN or maybe RST packets over TCP, UDP spam or ICMP spam. The thing is, all of these things should be expected to be of a fairly low volume. UDP is used for DNS and gaming, which shouldn't be too high bandwidth, ICMP is used for basically nothing so can almost certainly be safely limited, and it's pretty rare for a machine to need to make more than 10 connections per second, so a burst of 100 and an average of 15 ought to sort that out.
Not only is it useful to stop the spammage, but it must also be useful to be able to mail customers with "we suspect you've been rooted" when traffic consistently breaches these limits, with cutoffs threatened after a week or so without adequate explanation.
So, like I say, why doesn't this happen? Is it just too hard to track the data? Am I wrong about connection tracking being common? |
|
|
| navigation |
| [ |
viewing |
| |
most recent entries |
] |
| |
|
|