Tuesday, April 22, 2008

Hacked up a friendfeed widget with Feedburner

(permalink)
Paul Buchheit has a really nice friendfeed widget on his blog. I couldn't find any public source for the API, so I hacked up a quick one of my own.

It's not nearly as nice, but it does the trick. I imported my friendfeed RSS feed into feedburner, then set up a BuzzBoost widget which I incorporated into my blog's theme.


I modified the default BuzzBoost layout to look a little nicer, here's the CSS if anyone's interested (looking at the HTML of this blog might also help, I used my own div container and header div):


/* FriendFeed
----------------------------------------------- */
.friendfeed-border {
border: 2px solid #A7C5EA;
}

.friendfeed-header{
background-color: #A7C5EA;
width: 100%;
height: 1.4em;
background-image: url('http://friendfeed.com/static/images/logo-mini.png');
background-repeat: no-repeat;
text-align: right;
color: #333;
font:1.4em "Trebuchet MS",Trebuchet,Arial,Verdana,Sans-serif;
padding: 0.25em 0 0 0;
margin: 0 0 10px 0;
}


.friendfeed-header a {
color:#444;
text-decoration:none;
}

.friendfeed-header a:visited {
color:#444;
text-decoration:none;
}

.friendfeed-header a:hover {
color:#444;
text-decoration:underline;
}

.feedburnerFeedBlock {
padding: 0 .25em .25em .25em;
}

.feedTitle {
}

.feedburnerFeedBlock li {
background-image: url('http://friendfeed.com/static/images/icons/internal.png');
background-repeat: no-repeat;
padding: 0em 0em 0em 0em;
}

.feedburnerFeedBlock div {
margin: 0 20px 0 0;
}

.headline {
font-weight: bold;
margin: 0 0 0 22px;
}

.enclosure{
margin: 0 0 0 25px;
font-size: 50%;
}

.date{
padding: 0 0 0 0;
margin: 0 0 0 0;
font-size: 65%;
}

Sunday, April 20, 2008

MacBook security

(permalink)
wakeup photo
wakeup photo,
originally uploaded by odiosam.
A while back I found this howto on flickr: http://www.flickr.com/photos/omegastation/292845901/

It's pretty useful - every time your mac wakes up from sleep, it takes a photo and emails it to you (or to flickr!). That's cool, but I'd also like to record the internal / external IP address as well. That way, if my macbook is ever stolen, I have a photo of who's using it, AND their IP address.

This is what you'll need, if you want to do the same:
  • My workflow, to start with: http://sam.bluwiki.com/sam/take_picture_on_wake.zip
  • wget
  • A server to rsync into
  • Ability to set up password-less ssh for your server (see this howto
  • camcapture
  • sleepwatcher


1)Download my workflow

2) I put everything into ~/Stuff/Surveillance - you can put it wherever, but be sure to modify the workflow.

3) Download camcapture, and copy the binary into ~/Stuff/Surveillance

4) If you want to upload your photos to flickr, get a flickr account and read this.

5) Test the workflow

6) Save it as an application (I saved my into ~/Stuff)

7) Download camcapture

8) Download & install sleepwatcher 9)Open terminal and vim ~/.wakeup (Make sure you change the location of take_picture_on_wake.app to the directory that you saved it into):
#!/bin/sh
/usr/bin/automator /Users/so/Stuff/take_picture_on_wake.app

Make it executable:
chmod +x ./.wakeup

10) Restart and test!

Note: Most users would be better off using automator to download a copy of http://ipchicken.com / http://whatismyip.com for an internal IP address, using automator to create an archive of all the files (index.html with External IP, ipdata with internal IP, iSight.jpg, and then emailing all the files to an account they can check over the web (like gmail). This will eliminate the need to use wget / rsync.

Labels:

Friday, April 18, 2008

Django + Python + PHP(optional) + Lighttpd on Debian etch

(permalink)
Couldn't find any great howto, so here's how I did it:

It's a good idea to update apt-get:
apt-get update


I didn't want apache running on my system:
apache2ctl stop
update-rc.d -f apache2 remove


Install lighttpd:
apt-get install lighttpd


Uncomment these lines from /etc/lighttpd/lighttpd.conf:
server.pid-file = "/var/run/lighttpd.pid"
"mod_fastcgi",
"mod_rewrite",

(you may have to add mod_fastcgi in)



If you want PHP support:
apt-get install php5-cgi


Add this line to the bottom of /etc/php5/cgi/php.ini
cgi.fix_pathinfo = 1


Add this to the bottom of vim /etc/lighttpd/lighttpd.conf:
fastcgi.server = (
".php" => ((
"bin-path" => "/usr/bin/php5-cgi",
"socket" => "/tmp/php.socket"
))
)


And add index.php if it's not already there:
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )





Python / Django support:

I like python 2.5.1:
apt-get install python2.5-dev
which python
cd to location of python binary
ls -lh (make sure python is a symlink)
rm python
ln -s python2.5 python


subversion to get django (also just a useful tool to have)
apt-get install subversion


Make a dir to hold all your install files:
mkdir /var/installers
cd /var/installers


Download & install:
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py


Get flup for python support:
wget http://www.saddi.com/software/flup/dist/flup-0.5-py2.5.egg
easy_install flup-0.5-py2.5.egg


Django:
svn co http://code.djangoproject.com/svn/django/trunk/ ./django-trunk/
cd ./django-trunk
python setup.py install


Edit /etc/lighttpd/lighttpd.conf and change fastcgi.server to:
fastcgi.server = (
".php" => ((
"bin-path" => "/usr/bin/php5-cgi",
"socket" => "/tmp/php.socket"
)),
"django.fcgi" => (
"main" => (
"host" => "127.0.0.1",
"port" => 9090, #set the port numbers to what-eva you want
),
),
"admin.fcgi" => (
"admin" => (
"host" => "127.0.0.1",
"port" => 9091,
)
)
)

(notice php support - that's optional)


Add rewrite rules to lighttpd.conf:
url.rewrite-once = (
"^(/media.*)$" => "$1",
"^(/static.*)$" => "$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/admin/.*)$" => "/admin.fcgi$1",
"^(/.*)$" => "/django.fcgi$1"
)


Now make blank dummy files to prevent Lighttpd 404 errors:
vim /var/www/django.fcgi
vim /var/www/admin.fcgi


Now make a django project directory (www):
mkdir /var/django
cd /var/django


make a test project:
django-admin.py startproject testproject


Add the following line to the settings.py file of the django project on the server:
FORCE_SCRIPT_NAME = ''

(this prevents redirects to django.fcgi)

start the project:

cd ./testproject
python manage.py runfcgi method=prefork host=127.0.0.1 port=9090 pidfile=django.pid

Note - using port 127.0.0.1 for runfcgi doesn't limit lighttpd to only that interface. It's used for communication between lighttpd & runfcgi

now test!
http://your_server_ip


Mysql support (haven't tested to see if this works):
I run my database on a separate server, if you don't, you'll need to set up mysql server as well. There are plenty of HOWTOS on that, try googling around.

apt-get install mysql-client

(will add config instructions later, once I do them)

Install MySQLdb, which lets python easily talk to mysql (haven't yet tested/configured this):
apt-get install python-mysqldb

Labels: , , , ,

Sunday, April 06, 2008

An adventure in the fourth dimension...

(permalink)
I recently watched this insightful video of a presentation by Cliff Stoll at a recent TED conference.

I liked the video so much, I wanted to show my appreciation. I've decided to support Cliff's store - www.kleinbottle.com. I was going to buy a bottle - but why settle for that when you purchase an everyday wearable item... the Klein hat.

I have to admit... there is a bit of false advertising here. Cliff isn't actually selling Klein bottles, since it intersects itself (this creates an edge). Instead, you can think of it as a mobius strip (one side, one edge) - distorted to represent a Klein bottle in only 3 dimensions. A true Klein bottle needs a fourth division so that it does not intersect itself.

Come to think of it... since I can't observe the fourth spatial dimension... maybe this IS a true Klein bottle... hmmm... If so, I look forward the mind altering effects of wearing something that can only exist in four dimensions.

Either way, though, I'm pleased - it will at least make for some interesting looks as I walk around campus.

Labels: