Friday, April 20, 2012
Scala Test Plug-in for Sublime Text 2
Dev Days: Hacking, Open Source and Docs
Dev Days
Every month we have a "Dev Day" where engineers take a break from their projects and work on "other stuff". Most start-up engineering teams have a "Hack Day" where everyone gets to hack on anything they want as long as they ship and share it with the rest of the team. Of course we have Hack Days but we also have other types of Dev Days too. In fact, we have three types of Dev Days:- Hack Days
- Open Source Days
- Doc Days
Open Source Days
You know what Hack Days are so I'll move on quickly to Open Source Days. Just like most companies these days, Bizo uses a lot of open source software (OSS). We love OSS and the community of developers and companies that share it. Over the last few years, we've used plenty of OSS but we've also created and given back lots of code as well.Actually today is one of our Open Source Days so all the engineers are working on both new and old open source projects. You can check out our (growing) list of projects by visiting code.bizo.com. Over the years, we've created a lot of tools around AWS including s3cp, fakesdb, aws-tools (package of all CLI tools). We've also built a lot of stuff for Hadoop (Hive, etc) including csv-serde, gdata-storagehandler and our latest is a scala query language called revolute (still in development). In addition, we've have a wide variety of other awesome code including the awesome Joist, dependence.js, raphy-charts and other fun stuff!
Doc Days
Conclusion
Thursday, April 5, 2012
Implementation driven interfaces?
I've recently encountered some interesting pagination in the Google Groups admin interface. It starts off simple enough, nothing exciting here...
Instead of the usual 'Previous', we see 'First' on the next page.
Are they just being clever? Knowing that there's only one previous page? No such luck…
We've reached the end of the list. I hope you've found what you're looking for, otherwise start over from the beginning!
One has to wonder, who designed this interface? You can only go forward. If you overshoot, it's back to square one, then click, click, click… It's clear it does not have users in mind at all.
My guess is that it's based on some limitation in the backend storage or query mechanism. The system only allows forward navigation of query results, so the interface simply mirrors that…
What an incredibly frustrating experience! I'll never take simple pagination for granted again.
It's a good reminder to think about your users and how they will interact with the system. Mirroring the programming interface rarely works.
Wednesday, April 4, 2012
Capturing Client Side JS Errors on AWS
Background
Quick background, we have two major types of javascript that our customers and partners may use: analytics tags and ad tags. Both tags are javascript and share the same error capture code.
Another quick note is that we run on Amazon Web Services so this approach is based on some of these services including S3, CloudFront and EMR.
Implementation
Our client side JS is compiled from Coffeescript. I've created a couple of gists to show you what the error logging code looks like in Coffeescript.
Details
The example shows our ad tags trying to execute surrounded by a try/catch that captures the error and eventually results in loading an image appending the relevant error metadata.
AWS Details
The image that is loaded actually lives on CloudFront. The CloudFront distribution is setup with logging which means that requests are logged and delivered to a specified S3 bucket (usually within 24 hours). Every day we run an EMR job against the CloudFront request logs that generates a report summarizing the errors. And that is it. Pretty simple and this approach has worked for us.
Pre-emptive "this isn't perfect" response
Some of you may be thinking, "you may not get all requests!". CloudFront logs are not supposed to be used for 100% accurate reporting (although nothing is really 100%). In our case, we don't need to capture all errors rather we are looking for directional information.
Monday, April 2, 2012
Creating Plug-ins for Sublime Text 2
Create a new plug-in
import sublime, sublime_plugin class ExampleCommand(sublime_plugin.TextCommand): def run(self, edit): self.view.insert(edit, 0, "Hello, World!")
Make it do something cool
Run a command on the current file
def show_tests_panel(self): if not hasattr(self, 'output_view'): self.output_view = self.window().get_output_panel("tests") self.clear_test_view() self.window().run_command(" show_panel", {"panel": "output.tests"}) def clear_test_view(self): self.output_view.set_read_ only(False) edit = self.output_view.begin_edit() self.output_view.erase(edit, sublime.Region(0, self.output_view.size())) self.output_view.end_edit( edit) self.output_view.set_read_ only(True)
self.proc = subprocess.Popen("{my command}", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) thread.start_new_thread(self.read_stdout, ())
def read_stdout(self): while True: data = os.read(self.proc.stdout.fileno(), 2**15) if data != "": sublime.set_timeout(functools. partial(self.append_data, self.proc, data), 0) else: self.proc.stdout.close() break
def append_data(self, proc, data): self.output_view.set_read_only(False) edit = self.output_view.begin_edit() self.output_view.insert(edit, self.output_view.size(), data) self.output_view.end_edit( edit) self.output_view.set_read_ only(True)
Using the "quick panel" to search for files, and opening files
def file_selected(self, selected_index): if selected_index != -1: sublime.active_window().open_file(self.files[selected_ index])
Create keystroke bindings
[ { "keys": ["super+shift+e"], "command": "jump_to_scala_file" } ]
[ { "keys": ["super+shift+e"], "command": "jump_to_scala_file", "context" : [{"key": "selector", "operator": "equal", "operand": "source.scala", "match_all": true}]} ]
Conclusion
Resources
Official plug-in examples (sparse): http://www.sublimetext.com/
Official API reference: http://www.sublimetext.com/
https://github.com/maltize/
https://github.com/noklesta/
https://github.com/luqman/
https://github.com/rspec/
http://wbond.net/sublime_