Scott Kirkwood's Personal Blog
Programming, Brazil
Linux: Getting more excited about Linux
Get link
Facebook
Twitter
Pinterest
Email
Other Apps
I've been looking around and found some nice screenshots of peoples desktops using Gnome. Very nice. Looks like gDesklets is popular, which is cool since it's written in Python.
If you don't use unison to keep folders synchronized you really should, it's great. It's like a two way rsync program. Problem is I end up synchronizing a bunchy of folders in different locations for different projects and I prefer to start unison at the command-line. What I want is bash completion for unison. It's not that difficult to setup. I just created a file in /etc/bash_completion.d called "unison" and it looks like this: _unison() { local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" opts=$(python -c 'import glob,os,os.path;x = glob.glob(os.path.expanduser("~/.unison/*.prf")); print " ".join([os.path.split(y)[-1][:-4] for y in x])') COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 } complete -F _unison unison-gtk The python part is all one line and it goes to my ~/.unison folder, lists all the *.prf files and then just gets
Mark Byer's site has some more Sudoku solvers here's a short one in Python that's only 178 bytes long: def r(a):i=a.find('0');~i or exit(a);[m in[(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)or a[j]for j in range(81)]or r(a[:i]+m+a[i+1:])for m in'%d'%5**18] from sys import*;r(argv[1]) On the site is also shown a longer Perl version at 185 bytes: use integer;sub R{for$i(grep!$A[$_],@x=0..80){%t=map{$_/27-$i/27|$_%9/3-$i%9/3&&amp;amp;$_ /9-$i/9&&($_-$i)%9?0:$A[$_]=>1}@x;R($A[$i]=$_)for grep!$t{$_},1..9;return$A[$i]=0} die@A}@A=split//,<>;R I think the Python version is slightly easier to understand, although they are both quite cryptic. I'm not sure why I find these programs fascinating. I think it reminds me that any program can be written in such a way that it's cryptic, even in Python. In addition, the code is small enough that you should be able to figure out how it works, and may learn something the process. Related is
For fun I wasted some time creating diagrams using the dot language. It's pretty fast to get a diagram out, except that there are a lot of things you can't do, like make shadows or rounded and filled rectangles. With this dot code: digraph "User Clicks" { node [ shape="rectangle" style="filled" ] server [label="Server"] java [shape="ellipse" label="Java\nCode"] provider [label="Service\nProvider"] browser [label="Firefox"] browser->server[label=<① AJAX Sends Session ID>]; server->java[label=<② Confirms Session ID>]; java->provider[label=<③ Makes HTTPS call>]; provider->java[label=<④ Results>]; java->server[label=<⑤ Results>]; server->browser[label=<⑥ Results>]; } You can click on the image to see the SVG rendered in Firefox, if you use that. I wrote a little python program to call t
Comments