I got bored and wanted to see how many lines of code I had otherwise altered since winter break started.
The actual numbers are:
- Added: 1617
- Deleted: 1964
I've deleted a lot more than I have added. This is reasonable considering I've been doing quite a bit of code refactoring and I always end up with smaller code that does more.
I'm sure the method I used wasn't the cleanest or best method to go about finding these numbers, but I wasn't looking to spend more than 5 minutes figuring it out. Here's how I looked those numbers up:
% p4 diff -ds `find ./ | sed -e 's,$,@2005/12/20,'` > changes
% awk 'BEGIN { add = 0; del = 0; chg = 0 };
/^add/ { add += $4 };
/^deleted/ { del += $4 };
/^changed/ { chg += $4 };
END { printf "Add/Del/Chg: %d/%d/%d", add, del, chg}' changes
Add/Del/Chg: 326/10/139
% svn diff -r {2005-12-20}:head > diffs
% awk 'BEGIN {add = 0; del = 0}
/^-[^-]/ { add += 1};
/^+[^+]/ { del += 1 };
END { print add" "del}' diffs
1152 1815
Comments: 0 (view comments)
Tags: productivity
Permalink: /productivity/203
posted at: 06:31
Many of my mp3s are of such a high bitrate that they saturate my crappy 30k/s
DSL connection. To solve that problem, I wrote a proxy that connects to the
real shoutcast server and essentially pipes the output through lame before
sending it to you. Doing this, I was able to easily down encode any mp3 output
to something more reasonable for streaming, such as 64kbit.
If you want to take a look at it, it's only 38 lines of python.
lameproxy.py
This is probably going to become a part of Pimp itself. Instead of accessing the normal '/stream/happystream' you could do '/stream/happy?bitrate=128' and it will lame-it up for you. I've *always* wanted this feature in Pimp since version 2 (version 1 wasn't networked).
On a funnier note, it seems like the other media guys are catching on to
"networked is good" - XMMS2 is being written from scratch so I hear. It's going
to sport a client/server model. So far there's MPD2, XMMS2, and Gstreamer that
are well known. Whatever, as far as I can tell they all have the library and
player in the same place. Pimp abstracts it one more level: a control client, a
server, and a media client. In this case, the control client is Firefox and
media client is your favorite mp3 player. Those other projects will eventually
catch up to me I suppose ;)
Comments: 4 (view comments)
Tags: python, networking
Permalink: /geekery/202
posted at: 07:35
I posted this to freebsd-current@, so I might aswell post it here too.
I've been working on a userland-ification of psm(4) and a complete
rewrite of moused(8). The new psm(4) driver lacks protocol understanding
and expects to be controlled through ioctls only. The new moused(8) is
designed such that mouse drivers are in the userland.
I have implemented 3 driver modules thus far:
- Synaptics Touchpad (ps/2 only, not usb)
- Generic PS/2
- sysmouse (for ums(4) and mse(4))
Development has been done in 6.x (I don't have a -current machine handy)
but this will probably work fine in -current.
Directions on what to do can be found on the project's site:
projects/newpsm
Comments/suggestions welcome :)
Comments: 0 (view comments)
Tags: freebsd
Permalink: /geekery/201
posted at: 07:20
LINKS IN THIS DO NOT WORK
I've made some more cool changes to my javascript effects library thing. You
can see a demo of the two new effects here:
http://kenya.csh.rit.edu/static/test.html
Pimp's web interface is coming along smoothly. There are so many layers to this application it hurts!The server is python with json, xmlrpc, sqlite, and a few other pieces. The client is xhtml with javascript and css. There are so many places something can go wrong, whee!
I'll probably push my javascript stuff to this site as soon as it's finished. In the meantime, you can always look through my subversion repo.
Comments: 0 (view comments)
Tags: javascript, web, PERMABROKEN
Permalink: /geekery/200
posted at: 07:22
Whew! I don't think I've ever spent more hours on dead-end ideas on a project
in a very long time. Most of the ideas I tried failed miserably due to either
problems with design or problems with the underlying application. For instance, I found I couldn't return HTML from an XMLHTTPRequest call and append it to my document properly, ugh!
I've been doing a lot of brainstorming on how to spiff up the interface Pimp
4.0 is going to sport. I wanted to have a useful interface from the web that
also looked cool in the process - something many interface programmers desire
to achieve but almost always fall short.
There are a number of very good JavaScript library projects such as Prototype,
Scriptaculous, and others, so I figured I'd try them out and see what I could
do. Turns out, scriptaculous would be the most useful, but it doesn't work
under XHTML with content-type application/xhtml+xml.
Having hit a number of brick walls, I decided to scrap using other people's
code and write my own. I always learned more that way anyway.
The first step was to write a few small visual effects. The only two I've
needed so far have been fading in an out. It makes use of Accelimation, a
movement/acceleration library by Aaron Boodman over at youngpup.net.
After that, I wanted to reengineer the javascript bits for Pimp. So, I did
that. Instead of lots of loosly-glued-together functions, I have one javascript
"object" thing called 'Pimp' that has a number of functions. I was going to go
all Object Oriented and such, but doing OO in JavaScript with timers and such
is a pain in the ass. I gave up OO and went with a simpler approach, a
static-class-like objecty thing ... JavaScript is an interesting beast.
I also moved to using JSON for server-to-client communication. Clients still
send data using XMLRPC, but the responses are in JSON becuase there's no added
processing time for the client to handle it. Thankfully, it was easy to replace
the XMLRPC stuffs with JSON where necessary. I only had to update one function
on pimp's python stuffs and add an 'eval' line to the javascript.
Putting all of this together, Pimp's "Stream list" now updates smoothly in
realtime: New streams fade into the list and song changes are faded between on
the screen. I think it looks very cool, and doesn't detract from the usefulness
of the page. Another addition included fading between the "stream list" view
and the viewing an individual stream. The stream list will fade out while the
individual stream data loads (efficient waste of time, no?) followed by the
individual stream's page fading in.
If you want to see what I've done so far, let me know. It may not work when you ask due to active development, though! Anyhoo. If you're intrested, I'll be happy to show you.
My JavaScript brain-cells were rusty yesterday. I suppose they aren't anymore ;)
Comments: 0 (view comments)
Tags: ajax, python
Permalink: /web/199
posted at: 07:03
I've been gradually researching interesting ways to go about templating pages for Pimp 4.0 (rewrite in python). I've come to the conclusion that regexp replacement is hackish. Using a big templating toolkit is too much effort for now. However, I've come up with a solution I've yet to test thorougly, but the gist of it is:
Use an XML DOM parser to get a DOM-ified version of the webpage. Use XPath to find elements I want to modify and do so as necessary. Poof, templating.
A sample template is layout.html
The following python will parse it and insert "Testing" into the content div.
#!/usr/local/bin/python
import sys
from xml.dom import minidom
from xml import xpath
if __name__ == '__main__':
foo = minidom.parse("layout.html")
# Append a text node to the element with 'id="content"'
div = xpath.Evaluate("//*[@id='content']", foo.documentElement)
div[0].appendChild(foo.createTextNode("Testing"))
foo.writexml(sys.stdout)
It seems pretty simple. I'm probably going to come up with a simple-ish xml/xpath way of doing templating. We'll see how well it actually works later on, but for now it seems like a pretty simple way of doing templating. Move the complicated parts (complex xpath notions) to a templating class with an "insert text" or somesuch method and poof, simple templating. Even for complex situations where I may need to produce a table it is easy to provide a default node-tree for replicating. The particular DOM implementation I am using provides me a wonderful cloneNode() method with which to do this.
Ofcourse, if you know of any other simpler ways of doing templating in python (or in general) definitely let me know :)
Comments: 0 (view comments)
Tags: xml, web, python
Permalink: /geekery/198
posted at: 03:35
I already know how to setup ldap databases and add objects. Now I needed to figure out how to secure it and hook it to kerberos.
The following in my slapd.conf maps kerberos users to ldap objects.
authz-regexp uid=([^,]*),cn=gssapi,cn=auth
"ldap:///ou=Users,dc=csh,dc=rit,dc=edu??sub?(uid=$1)"
When you have kerberos ticket and authenticate using SASL, you will bind as 'uid=USER,cn=gssapi,cn=auth' - this is not the proper ldap object for any user on my system. Luckily, I can substitute this dn for a valid one using 'authz-regexp.' What this does, essentially, is do a subquery when you authenticate via SASL and looks for objects in the Users orgunit with a uid=USER. Very very helpful. Now I can get a kerberos ticket and ldap knows who I am:
nightfall(~) [976] % kinit
psionic@CSH.RIT.EDU's Password:
kinit: NOTICE: ticket renewable lifetime is 0
nightfall(~) [977] % ldapwhoami
SASL/GSSAPI authentication started
SASL username: psionic@CSH.RIT.EDU
SASL SSF: 56
SASL installing layers
dn:cn=jordan sissel,ou=users,dc=csh,dc=rit,dc=edu
Result: Success (0)
Wonderful! The next step was to allow users to modify their own objects. A short ACL entry in slapd.conf fixes that.
access to attrs=gecos,description,loginShell,mail by self write
This ACL ensures that users only have write access to themselves, and even then only to the attributes listed above. To test this, I did the following:
nightfall(~) [981] % ldapsearch -Q -LLL '(uid=psionic)' 'loginShell'
dn: cn=Jordan Sissel,ou=Users,dc=csh,dc=rit,dc=edu
loginShell: /test/baz/fizz
nightfall(~) [982] % cat myldif
dn: cn=jordan sissel,ou=users,dc=csh,dc=rit,dc=edu
changetype: modify
replace: loginShell
loginShell: Happy Login Shell
nightfall(~) [983] % ldapmodify -Q -f myldif
modifying entry "cn=jordan sissel,ou=users,dc=csh,dc=rit,dc=edu"
ghtfall(~) [984] !1! % !ldapse
ldapsearch -Q -LLL '(uid=psionic)' 'loginShell'
dn: cn=Jordan Sissel,ou=Users,dc=csh,dc=rit,dc=edu
loginShell: Happy Login Shell
Users have write access to their own objects now.
The next step is going to be getting SSL/TLS working. I made a brief attempt at doing that tonight but I failed. Getting some SSLv3 handshake error that is clearly PEBCAK on my part. Oh well, sleep now. More LDAP later.
Comments: 0 (view comments)
Tags: unix, ldap
Permalink: /geekery/197
posted at: 04:47
We at CSH need to move from nis and the many other user information datastores we use to using LDAP instead. To that effort, I have started working on merging our data informations. The first step is importing NIS (passwd/group) information into ldap.
I wrote a script, passwd2ldif, to use NIS passwd information and put it in ldap.
ypcat passwd | ./passwd2ldif > cshusers.ldif
ldapadd -D "cn=happyrootuserthinghere,dc=csh,dc=rit,dc=edu" -f cshusers.ldif
Wait a while, and all users from NIS show up in ldap. I have my laptop looking at ldap for user informatin using nss_ldap:
nightfall(~) [690] % finger -m psionic
Login: psionic Name: Jordan Sissel
Directory: /u9/psionic Shell: /usr/bin/tcsh
Never logged in.
No Mail.
No Plan.
Pretty simple stuff, so far. Next step is going to involve creating a new
schema to support all of the information we currently store in "member
profiles." Member profiles is a huge mess of a single mysql table with lots of
columns such as "rit_phone," "csh_year," "aol_im," and others. All of that can go to ldap.
I'll post more on this later when I figure out what kind of schema we want.
Comments: 0 (view comments)
Tags: unix, networking, productivity, ldap
Permalink: /productivity/196
posted at: 02:26
|
Search this site
Navigation
Metadata
Home
About
Resume
My Code (SVN)
ARP Security
Dynamic DNS with DHCP
OpenLDAP+Kerberos+SASL
PPP over SSH
SSH Security: /bin/false
Week of Unix Tools
Work Efficiency
fex
firefox tabsearch
firefox urledit
grok
keynav
liboverride
newpsm (FreeBSD)
nis2ldap
pam_captcha
poor man's backup
Solaris audio utility
xboxproxy
xdotool
xmlpresenter
xpathtool
misc scripts
Presentations
Yahoo! Hack Day '06
Unix Essentials
Vi/Vim Essentials
Tag Cloud
Calendar
| < |
December 2005 |
> |
| | | | | 1 | 2 | 3 |
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Friends
BarCamp
Kent Brewster
Tantek Çelik
John Resig
Wesley Shields
Tyler Shields
Technorati
|