Here I am trying to learn Japanese, but I don’t know any curse words. I always figured that I’d pick them up if I ever spent time in Japan, but it seems that the Japanese take a different approach:
Sat 28 Oct 2006
Here I am trying to learn Japanese, but I don’t know any curse words. I always figured that I’d pick them up if I ever spent time in Japan, but it seems that the Japanese take a different approach:
Fri 27 Oct 2006
Today I replaced “.NET” with “JavaScript” in my byline above. After all, I haven’t done .NET programming in well over two years and I do JavaScript on a daily basis. And with that simple flip of some bits, balance has been restored to the force, and the peasants rejoiced.
Thu 26 Oct 2006
So Firefox 2 is out, and it looks much like its predecessor. The upgrade was painless, nothing broke. So what, exactly, changed? Well one thing is that it has support for JavaScript 1.7, which (among other things) includes support for array comprehensions via iterators, generators, and other Pythonic things.
What caught my eye was that it supports map natively. For anyone using Prototype and getting annoyed with its performance, this could be a big thing. In a few simple tests I found that the exact same loop code runs 2-3 times faster with the native map as compared to Prototype’s implementation. If we could somehow harness that power…
Thu 26 Oct 2006
I’m selling a phone on eBay for a friend, but since the last time I used eBay it seems to have been taken over by Nigerian scammers. The winning bid on my item was a scammer, and after many emails (mostly automated) from eBay and PayPal regarding this situation, here’s my response:
Hello,
I appreciate the support I’ve received so far regarding my sale of this item, however I find it lacking and I think you could do better. I feel as though I’m discussing this issue with three different entities: two branches of eBay and PayPal (which is now an eBay company). Therefore my experience is quite fragmented and, unfortunately, could be quite confusing if I didn’t already have a fairly firm grasp on what’s going on. I’d appreciate if you could deliver some of the following comments and suggestions to the appropriate person.
First I sent an email, to which yours was the reply, stating that the buyer had violated the listing terms. At this time I was relatively new to 419 scams and was under the impression that as long as the money had showed up in my account, all was good. It’s a good thing I am naturally skeptical and that I searched google for information about these scams - it was much more informative than reading the eBay support pages (particularly http://en.wikipedia.org/wiki/Advance_fee_fraud). Perhaps you could have a fairly straightforward help section titled “What to do if you believe you may be the victim of a scam”. After all, the whole reason that I didn’t notify eBay of any fraud is because I didn’t know about the possibility of this sort of scam. So I chose the next one down that made sense: violation of listing terms.
PayPal then contacted me to notify me that the payment I’d received was made with fraudulent funds. While it cautioned me to not deliver the goods or services related to those funds, it seems to me that PayPal should be able to determine what the funds were for. After all, my PayPal and eBay accounts are linked. I believe doing so would provide a more cohesive experience for the user.
Days later I received an Administrative Bid Cancellation notice regarding the item, which was, of course, a form letter and took into account neither my previous inquiry nor PayPal’s reversal of payment. I understand that machines are much cheaper than people and that it is infeasible to attach a person to every fraud case, but you should strive to make your software act with some degree of intelligence - a little effort in this area could go a long way.
Finally I received a response to my initial inquiry. This response took none of the other factors into account. It would have been very quick to look up the status of the item and see that there had been an Administrative Bid Cancellation and that, therefore, it is ill-advised to offer instructions on how to accept the bid. Again, I understand that you can’t have people spending lots of time on these things, but slightly smarter software could help a lot here.
Overall eBay has the feeling of a big company with all the good and bad that statement entails. Dealing with phishing, stolen credit cards, unauthorized bids, etc is a hard problem and I don’t envy your position. The one thing you do have under your control is your customer service, and that has lots of room for improvement. Thank you for taking the time to read this email. Feel free to contact me if you’d like any clarifications.
-bd
Mon 23 Oct 2006
Simple and easy javascript dependency management.
This plugin grew out of my desire to use javascript effectively in my new job. We began using UJS, and that was a good step in the right direction. The problem was that I found myself wanting to break the code I was writing into logical sections, so I created this convention:
The url /account/edit automatically includes /javascripts/account/edit.js if it exists, otherwise it would try /javascripts/account.js, and otherwise nothing. This convention worked pretty well, except that I found that often controllers would share code. I could have just included the controller javascript as well, but on top of that there was another convention: /javascripts/models/base.js, which communicates with the server (getting JSON back), and its subclasses. Controllers didn’t have a 1-1 mapping to models, so I needed some mechanism to specify what should be included where without a bunch of conditional statements in application.rhtml.
My solution (from one index.js):
// require prototype menu models/tag models/interest builder moo.fx.pack.js
This is the first line of the file, and it tells my plugin to make sure that it includes these files before it includes this one when using javascript_include_tag. So the output of javascript_include_tag('index') would be this:
<script type="text/javascript" src="/javascripts/prototype.js"></script>
<script type="text/javascript" src="/javascripts/menu.js"></script>
<script type="text/javascript" src="/javascripts/models/tag.js"></script>
<script type="text/javascript" src="/javascripts/models/interest.js"></script>
<script type="text/javascript" src="/javascripts/builder.js"></script>
<script type="text/javascript" src="/javascripts/moo.fx.pack.js"></script>
It also handles recursive includes:
A.js: // require B …
B.js: // require C …
C.js: …
Here calling javascript_include_tag('A') returns:
<script type="text/javascript" src="/javascript/C.js"></script>
<script type="text/javascript" src="/javascript/B.js"></script>
<script type="text/javascript" src="/javascript/A.js"></script>
And, if two different scripts require the same script, it’ll only be included once:
A.js: // require prototype …
B.js: // require prototype
javascript_include_tag('A', 'B'):
<script type="text/javascript" src="/javascript/prototype.js"></script>
<script type="text/javascript" src="/javascript/A.js"></script>
<script type="text/javascript" src="/javascript/B.js"></script>
This even works if you include ‘A’ and ‘B’ in different calls to javascript_include_tag.
script/plugin install http://eventualbuddha.textdrive.com/svn/javascript_require/
Mon 23 Oct 2006
Having a full-time Rails job can really spur you to find out more about what’s going on in Ruby and Rails. I’ve found that I’ve learned quite a bit about what’s going on in the last month and that I’m still learning at a breakneck pace, so here goes, in no particular order:
“Vendor branch management” gem that lets you store other projects (like Rails plugins) inside your own repository while retaining the ability to update them. This is particularly useful with Rails because you don’t really want to have outbound connections fetching your svn:externals every time you do a Capistrano deploy.
All my svn:externals have been Piston-ized.
A Rails plugin that allows building the ActiveRecord find options hash based on Ruby code:
Article.findwhere(:all) { |article| article.publishedat < => (from..to) }
Great for complex queries. Using this plugin in WishRadar cut about 45 lines of code that generated SQL manually into about 12 of easy-to-read ruby.
An “Official” Rails plugin to make it easy to set up continuous integration testing with email and Campfire notification support. I’ve been using this for about two weeks and it’s pretty reliable, though setting it up with a Subversion post-commit and getting migrations to run is a little tricky. My hacked continuous_builder.rb’s make method:
def make
@output = cd #{@options[:application_root]} && #{@options[:bin_path]}rake db:migrate RAILS_ENV=test && #{@options[:bin_path]}rake db:migrate RAILS_ENV=development && #{@options[:bin_path]}rake #{@options[:task_name]} RAILS_ENV=test
make_successful?
end
To prevent Subversion from blocking when doing a commit, run scripts with STDERR redirected to STDOUT and put the process in the background:
/path/to/continuous-builder 2>&1 &
Wonderful list of stuff to use on a Rails site if you’re serious about going to production.
They’ve started work on an app to make it easy to produce diffs for documentation purposes. Better Rails docs now!
A large fixture set is very hard to manage, so a plugin to keep them in discrete ’scenarios’ making them independent and “preventing you from changing your assumptions in a dangerous way” is a great idea. Beware, though - it may not play nice with other fixture-related plugins. (in case you’re wondering, it’s better than FixtureSets)
A network-enabled memory store that basically acts like a giant hash. Good for sessions and whatever other data you need to cache in your app. See the article. Haven’t used it much but I’m looking forward to it (trying to avoid the premature optimization itch).
A plugin to print a stack trace with each SQL query in your logs. This hasn’t proved invaluable yet, but I’m guessing that once we start optimizing our queries and caching, it’ll be a lifesaver.
Fast - like C fast - forgiving HTML parsing. Yeah baby.
This will include ActiveResource, DHH’s latest code built to tackle one half of the REST web services problem, as well as some nifty enhancements to routes that will cover the other half.
Unit testing done in a more DSLish way. Specify what should happen, and in what contexts, and you’re halfway done with your tests. Really more of a psychological helper than anything else, but that’s what good DSLs are for, right? Check it out at rubyforge. I haven’t tried this yet, but it’s on my list.
Thu 19 Oct 2006
One of my biggest annoyances with Firebug was that when you are in the Inspector and wish to get an element into the console, you have to use some JS hackery in order to do it. Well, at some point this limitation was removed — or it never really existed except in my head. All you have to do is reference $1 in the console. Yay!