This post marks 4 in one day. Whew!
Resig and I were bouncing ideas around after
I made the form filler, and we came up with something that fits very nicely
into the jQuery api (in the form of something very pluggable).
You'll need the following code that will extend jQuery's functionality.
Basically, it adds 'saveAsCookie' and 'loadAsCookie' function calls to
$() objects.
$.fn.saveAsCookie = function(n,t){
return this.each(function(){
createCookie( (n || '') + (this.name || this.id), this.value, t );
});
};
$.fn.loadAsCookie = function(n){
return this.each(function(){
this.value = readCookie( (n || '') + (this.name || this.id) );
});
};
You can safely put that code somewhere and load it anywhere you need autofill. Reusable code is awesome.
Now, we don't want to cache *all* input elements, becuase only some contain
user-input and only some need to be saved. For this, I put the class 'cookieme'
on all input elements I wanted to save.
$(document).ready(function(){
$("form#comments_form").submit(function(){
$("input.cookieme",this).saveAsCookie("formdata");
})
.find("input.cookieme").loadAsCookie("formdata");
});
The arguments to 'saveAsCookie' and 'loadAsCookie' are namespace prefixes. This way, you can avoid namespace collisions with other cookies. All of my autofill cookies will be prefixed with 'formdata' and suffixed with the element name or id attribute.
So, we squished the code down to 6 lines, 4 of which are actually meaningful.
jQuery++
Comments: 5 (view comments)
Tags: jquery, javascript, site, user experience
Permalink: /geekery/jquery-formfill-v2
posted at: 05:38
It's always nice when websites you commonly visit remember things about you, or
atleast give the perception that they remember things about you.
The Pyblosxom comment plugin doesn't autofill the form. That's too bad. I don't
really want to dig into the python code to do any cookie-setting on submission,
becuase I have never looked at the code and thusly am unfamiliar with the
effort required for such a change. Luckily, we can use javascript to store data
in cookies too!
I love jQuery, so that's what I'll use for this little hack. On the comments page, I add the following javascript:
var uname = "u.name";
var uemail = "u.email";
var usite = "u.site";
function saveCommentInformation() {
// Save user information from the form!
createCookie(uname, $("input[@name='author']").val());
createCookie(uemail, $("input[@name='email']").val());
createCookie(usite, $("input[@name='url']").val());
}
function initCommentForm() {
// Autofill user information if available
$("input[@name='author']").val(readCookie(uname));
$("input[@name='email']").val(readCookie(uemail));
$("input[@name='url']").val(readCookie(usite));
// Save comment information when form is submitted
$("form[@name='comments_form']").submit(saveCommentInformation);
}
$(document).ready(initCommentForm);
That's all we need. Whenever someone submits, we will store useful information in a cookie. Whenever that person comes back, we'll pull the data out of the cookie and put it back in the form. User Experience is happier, atleast as far as I am concerned (as a user).
If you are wondering about the 'readCookie' and 'createCookie' functions, you
can find them on quirksmode.org:
http://www.quirksmode.org/js/cookies.html
Comments: 14 (view comments)
Tags: jquery, javascript, site, user experience
Permalink: /geekery/jquery-formfill-v1
posted at: 01:52
Subject says it all. I've really wanted comments working in pyblosxom 1.3 for quite some time. However, all googling points to old versions of the comments plugin that only works on the older versions. I checked the pyblosxom page tonight and was pleasantly surprised that a contributed plugin set had been released early this month.
If you use pyblosxom 1.3.x, plugin updates are ready for your use.
On that note, comment functionality is FINALLY here on this site. To those of you reading this site, feel free to comment! I love feedback.
Go to the pyblosxom website
Comments: 0 (view comments)
Tags: site, pyblosxom, community
Permalink: /productivity/pyblosxom-plugins-1.3-out-finally
posted at: 01:18
Sometimes I run commands that have special characters in them, newlines, or are very long. 'xterm set title' sequence breaks on those cases. So, let's fix that.
function title() {
# escape '%' chars in $1, make nonprintables visible
a=${(V)1//\%/\%\%}
# Truncate command, and join lines.
a=$(print -Pn "%40>...>$a" | tr -d "\n")
case $TERM in
screen)
print -Pn "\e]2;$a @ $2\a" # plain xterm title
print -Pn "\ek$a\e\\" # screen title (in ^A")
print -Pn "\e_$2 \e\\" # screen location
;;
xterm*|rxvt)
print -Pn "\e]2;$a @ $2\a" # plain xterm title
;;
esac
}
The 3 cases are addressed individually.
- Special characters are made printable by using the 'V' flag, ${(V)varname}. This is documented in zsh under 'Parameter Expansion Flags'
- Long lines are truncated with "%40>...>$varname" with "print -P". The '-P' flag has print interpret in prompt-style expansion. "%40>...>whatever" will truncate 'whatever' to 40 characters, trailed with '...'
- Multi-line entries are joined with 'tr -d "\n"' - Maybe there's a better way to do this with zsh without needing to run tr(1) every time?
The 'title' function takes 2 arguments, which get separated by a '-' in xterm titles. First argument is the 'what' and second argument is the 'where'. Separated, they can be used to tell screen what is running ina given session and where. Useful++
The only real changes to this function from the original was adding the fixes for those 3 cases. The rest of the function remains unchanged.
If you're still confused as to where this can be used, put it in a precmd and preexec function:
# precmd is called just before the prompt is printed
function precmd() {
title "zsh" "%m(%55<...<%~)"
}
# preexec is called just before any command line is executed
function preexec() {
title "$1" "%m(%35<...<%~)"
}
An example of this can be seen in this screenshot.
Comments: 6 (view comments)
Tags: zsh, xterm, usability
Permalink: /productivity/better-zsh-xterm-title-fix
posted at: 21:54
- Write/find a non-crappy, very simple comment plugin for pyblosxom.
- Write/find a better tab-searchy extension than Reveal
- Rework grok's config syntax to do more with less typing
- Sleep
If you have any suggestions for the 'find'-type items, let me know :)
Comments: 0 (view comments)
Tags: ideas, grok, firefox
Permalink: /geekery/project-ideas
posted at: 03:51
If you're reading this and were at BarCamp San Francisco, I was the guy wearing
pajamas throughout the event. Shoot me an email, let's keep in touch.
I'd been meaning to write a general summary of the kinds of technologies
prevalent at this BarCamp, so here it is: The typical "Web 2.0" demos and
discussions were present, aswell as political and legal discussions. Lots of
Drupal fans were also here; I keep hearing more and more about Drupal as time
goes on. This BarCamp seemed to have a greater focus on mobile technology and
microformats. Unfortunately, I didn't get around to finding time to attend the
mobile technology sessions. Along with that were a large number of
microformats-oriented sessions, which were cool. A few of the technorati guys
were here and were big pushers of microformats. There was also a great deal of
schwag to be had. I picked up a few T-shirts, a mug, some stickers, etc.
The last day (sad!) of BarCamp was today. The numbers have dwindled somewhat as
folks went home never to return. I attended a lightning talk on S5 and a very cool introduction to
Microsoft's Atlas framework. I was hoping to see a whole track dedicated to
lightning talks (aka speed geeking?). I'm sad to go, but I'm bound to go to more
BarCamps after this one, my second barcamp.
S5 is a simple web-based presentation software. It has features that make me say
"Hey, I want that in my presentation software!" It's standards compliant and
uses microformats. It's a very neat, simple, easy, and new-tech presentation
technology.
Atlas is the first framework I've been exposed to that incorporates client and
server code generation and interaction. It's cool to see how you can expose C#
functions to websites via ASP and JavaScript. I'm certain other frameworks exist
to do similar things, but I'm not in the market for it so I don't know about
them. Cool presentation.
I gave my Unix and Vim presentations today, which was sort of the impetus for
the S5 presentation, so that others (including me) could learn about S5 and it's
coolness. My future presentations will likely be using S5, now that it's
matured. I'm told lots of extremely useful features are in testing and should be
released soon.
So much for not my worry of not having anything to present on, eh? 6 sessions of
various kinds, and I attended many more. I'm flat-out exhausted, but I can't
stop thinking about the weekend.
It's more than just the sessions that make BarCamp worth it to me. New
technologies are really cool to see. Everyone like demos, right? My favorite
part about BarCamp is meeting the people. Camps and conferences like BarCamp
create such a useful avenue to talk to fellow geeks, business folk, lawyers, and
whoever else attends. The greater portion of last night was spent talking about
lots of random socio-political geek stuff. Talking to industry and non-industry
people about where they think the mad train of technology is headed. Everyone
seems to be willing to talk to everyone else. That's my kind of town.
A super mega huge thanks to Microsoft for hosting, all of the great sponsors
(coffee!), and everyone who helped make this event a huge success. Who knows?
Maybe large corporations will see this event at Microsoft's office as a sign
that they, too, can host a BarCamp, or sponsor another BarCamp-style event.
BarCampEarth is coming in 2 months. I haven't
seen anything about a bay area camp for BarCampEarth. Maybe if I find some
time and others to help plan, perhaps we'll have a BarCamp in the area for
BarCampEarth?
For now, it's back to the Real World. Riding BART back has actually provided me
a great opportunity for writing and reflecting about the event and the weekend.
Double-plus for rapid transit!
In closing: S5, Atlas, AJAX is still in, microformats, *Camp Network Kit,
social geekery, and beer.
Comments: 0 (view comments)
Tags: barcampsf, barcamp, travel, geekery
Permalink: /geekery/barcamp-sanfrancisco-3
posted at: 14:02
8am wake up. Concrete is bad for good sleep.
The concrete flooring here at the Microsoft office was certainly not the most
comfortable. I woke up a number of times to adjust position. Oh well, I got
sleep. It's not quite BarCamp if I don't sleep over, right? ;)
I held 4 sessions today, wow! Here goes for a summary of them:
In keeping with tradition, I gave an introductory presentation on AJAX. There
was good attendance, and as in NYC there were still a great number of people
who came to BarCamp but don't have huge clue about what some of these
technologies actually are. I'm always glad to spread the clue. I also held a
discussion about productivity software. During the productivity session,
someone introduced me to ActiveWords.
I watched some of the demo videos and I was left fairly impressed with the
capabilities. Check it out for yourself if you run Windows, it's quite cool.
Later today I was approached by a man who introduced himself as "Buzz" asking
if I'm the guy with the pajamas. Turns out, this is Buzz Bruggeman, big whig man at
ActiveWords Systems, Inc. Neat! He sat me down and showed me all of the cool
things he does with ActiveWords. As a result, I found out about some new
productivity software, and for that I consider the productivity session a huge
success, personally.
ActiveWords is super cool. It addresses one of my bigger issues with computer
interaction: Impulse-driven use is nearly impossible. Let me explain. Everyone
has impulses during workflow. For instance, "I want to bring up gmail" -
simple, right? First I've got to find firefox in the taskbar, bring it up,
assuming I can find the particular firefox window I need. Then I have to hunt
through a series of tabs which may or may not have useful information in the
icon and titles. Hopefully I eventually find it, right? Quickly? Probably not.
Why can't I just say "bring up gmail" and have it happen just like I described,
but without the need for any extra effort on my part? You can't, though.
ActiveWords attempts to address that. I was relieved with the ease by which it
seemed you can do all of this impulse-driven work flow with ActiveWords.
Buzz is certainly a good salesman, I was sold after a few minutes. While I may
not buy it, because my work environment is unix, I'm happy to plug it. I'm
installing it as I'm writing this, so I'll review it shortly. Meanwhile, back
to BarCamp SanFrancisco!
Where was I? It's about 11:30pm. There's a physician blogger sitting down the
hall who many people are polling about funky medical questions and such.
Sessions, right. After the AJAX and productivity sessions, I mingled with many
of the fine folks here at BarCamp. I think Chris Messina put it best when he
described BarCamp as putting the hallway-type conversations in the spotlight.
That is, conversations people have outside of the scope of work and deadlines
and whatnot. Those are the best conversations anyway, right?
The next session I held was a firewall bypass session, mostly covering the use
of SSH to tunnel traffic (for fun and profit?). Those in attendance seemed to
think it was cool, so success there. I'll post notes to the BarCamp wiki later.
The next session I helped orchestrate was the "BarCamp Network Kit" project.
The impetus for this session was due to random networking issues plagueing the
network this morning and through the early afternon. I rememebered how
BarCampNYC had lots of slow network issues, so I put up a session to discuss a
potential "BarCamp Network In A Box" project. There were a good deal of strong
network/sysadmin people here, The results of our discussion can be found www.barcamp.org/StarCampNetworkKit.
With luck and lots of collaboration, and assuming someone steps up for
organizing a BarCampEarth event in the bay area, perhaps the network kit can be
demonstrated then?
[2 hours later...] I took a break from writing and went with some folks to a
bar in North Beach(?). Something around 20th and Mission. Car bombs, talking about work, talking about other interests, and further alcohol consumption. Good times.
So it's not 3AM, and I'm exhausted from today's activities. Tonight is much
better than the last, as many people are still awake. Two (swedish?) folks are
working on getting some WordPress thing running, others are discussing politics
and technology. I've been doing some ad-hoc sysadmin help for a folks that have
been fighting the typical LAMP stuff just to get some form of blog or website
online. It really ought to be easier to get a website up, eh? One particular
instance was Debian running Apache2. I'm used to Apache2 built from source, but
Debian makes *lots* of changes downstream before packages get to users. Why? Is
it too much to ask for a bit of consistency?
There's been some interest in both my vim and unix seminars, so I'll probably do both tomorrow. Anyway, it's getting to be quite the naptime. I'm looking forward to tomorrow's events.
Comments: 0 (view comments)
Tags: barcampsf, barcamp, travel, productivity
Permalink: /geekery/barcamp-sanfrancisco-2
posted at: 06:11
Lots of people are here. The venue is huge compared to BarCamp NYC's
venue, which is great considering the number of people in attendance.
The People:
There are quite a few people I know here, which is surprising
considering I've only been in the area for 3 weeks. Some BarCamp NYC
attendees, coworkers, and a friend from Yahoo, so far. I initially
started helping with sign-in so I met lots of folks at the door. Later
time was spent wandering around and chatting about various interests.
Meeting new folks is definitely still not my forte, but I seem to be
doing decently. The two folks I know from BarCamp NYC recognized me by
my pajamas. I tried to find a photo of said event with my pajamas
featured but Flickr doesn't seem to let you search by comments. At any
rate, there's a lot of people in attendance so the next two days should
be quite fun. There's a few VCs here, marketing and other types. On the
whole, there's mostly geeks. The type of geek ranges from high-up
engineers to self-employed consultants to I-just-do-this-in-my-free-time
hackers.
The Venue: Microsoft is this camp's host. The office is very large and
has a number of conference rooms. There are 8 presentation areas setup
for this camp. That's probably more than is necessary, but more is
always better than less. It's ironic considering the location and the
openness of the event. That is, how the common view of Microsoft is of an
evil megacorp, while it is the host to an incredibly successful open-style
conference. Thanks for the venue, Microsoft!
Between final exams, moving, situating with a new job at Google, etc, I
haven't had any time to work on new projects. Therefore, I don't really
have anything to present on. However, I'm considering having a BoF-type
session where we share ideas on computing productivity. I'm always
finding irritating barriers in software that have solutions available
but I don't know about them and don't seem to find them while searching.
We'll see.
Common interests seem to be Flock, Drupal, social networking, etc. Seems
like a similar set of interests and people as at BarCamp NYC. Have the
last 5 months sat idle amongst the "new software technology" community?
I can't tell, but I'm sure I'll find out tomorrow. Either way, I'm
looking forward to the presentations.
I'll poll tomorrow for feedback on what I probably should present on, but
current ideas are: anti-hype presentation discussing AJAX (what it is, what
it's not? where it may be going) or general productivity to find/share what
people use to make computing use easier.
Comments: 0 (view comments)
Tags: barcampsf, barcamp, travel
Permalink: /geekery/barcamp-sanfrancisco-1
posted at: 07:13
My work environment has changed drastically as I become more dependent on
Firefox to feed me information from the web. As such, I often have more and
more tabs open as the day progresses. Closing a tab is annoying, becuase in 15
minutes I'll probably need that page again. Since I don't close tabs often, I
end up with a huge tab list when the only thing I can see in the tab itself is
the favicon.
Obviously, searching for a tab is extremely difficult when all you have for
identification is horizontal location and a tiny icon. I had previously
resorted to a Monte Carlo-style method of finding tabs, which is just a fancy
term for "keep clicking random tabs until you find the right one." Again, this
has the obvious side effect of wasting time and annoying me.
I set out yesterday to write a Firefox extension to solve this issue. I've got
a prototype working pretty well, but a friend recently pointed me at Reveal. Reveal is a Firefox
extension that lets me search titles and urls of open tabs for a page I'd like
to view. It can search the page text, but I imagine that it is quite cpu
intensive, so I don't bother. I installed it, and while I don't care for the
thumbnails, the searching is fast and useful. However, I have doubts of it's
speed when running on slower machines (this particular desktop is 3.4gHz).
With about 15-20 tabs open, it seems to perform pretty well. I am uncertain as
to how well it scales. Being able to turn thumbnailing off entirely might be an
option worth trying. For now, Reveal solves the problem well enough.
I have lots of ideas about how to search pages quickly without having to search
the entire text content - like only looking at "important" tags such as the
H1-H6 series, etc. I haven't needed page text searching yet, though, so I'll
wait on spending time on that particular problem.
Comments: 0 (view comments)
Tags: firefox, extensions, tabs, productivity
Permalink: /productivity/firefox-with-too-many-tabs
posted at: 14:14
|
Search this site
Navigation
Metadata
Home
About
Resume
My Code
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
Friends
BarCamp
Kent Brewster
Tantek Çelik
John Resig
Wesley Shields
Tyler Shields
Technorati
|