Sit for the web, code, startups, and all that jazz
Joe Armstrong (Erlang) once said "The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle."
Lately, I've been looking at more information visualizations, and it's not been said enough that simple geometry is often ignored.
Often times, I'll see visualizations like this, where bubbles are employed to visually compare different records. It seems likely that people judge and compare difference in size by area. However, the artist/designer makes the mistake of mapping the data to the radius instead. This doesn't work for circles because of your old 4th grade math, stating that A = pi * r^2, where the area doesn't increase linearly as a proportion of the radius.
For the record, it's done correctly here in the visualization above, as far as I can tell.

Here, the designer decided to use triangles. If he mapped the data to the height of the triangles, that's fine, because for triangles, A = 0.5 * b * h, and hence area varies in linear proportion to height.
However, looking at Hungary, the red triangle doesn't seem quite a quarter of the black triangle.
Beyond that, for these two examples, I really see no reason to use circles or triangles. People are able to judge spatial difference much more easily, as opposed to size. It would have been far more effective to use bar charts and rectangles instead of shapes like triangles and circles. In my opinion, you only use that if the spatial x and y axis are already being used to convey other information already.
Ever since I quit my job at the lab 4 years ago to pursue a startup, I'd been fumbling around learning all sorts of things. And though I had determination and persistence, I simply didn't know a lot of things outside of coding. Who wants this? Why would they pay money for it? Where do you find them? How do you change your idea if it doesn't work? Going into it, I knew I didn't know anything and that I'd learn, but I also didn't know what I didn't know.
For the past year and a half, I've been with a startup that went into the YC program. So as much as I wanted to pursue my own ideas, I was advised to join up and watch other people and learn. And learn a lot I did. What to do, and what not to do. And just seeing founder from other startups helped. What their thought processes and attitudes about their line was work was. Meeting role models are easier than reading about them, I guess.
And yet, while I've been learning about things outside of code, I felt like I've been sailing downwind when it came to technical things. Sure, I'd mess around with chickens flocking (which embarrassingly, I haven't gotten back to), but for the most part, I was consumed by work. Getting the tickets done and getting better at communicating with other team members.
However, much of my creativity was sapped. It was hard to fire up the editor afterwards and explore something new. I have a whole list of things I wanted to dive into more deeply. Haskell's type system. Erlang servers. Spatial trees for Frock. Arc language. Potion language. Prof Strang's Linear Algebra lectures. Visualizations and info graphics. Mobile web apps. 3D printers. And though I've dabbled in all of the above, it's not yet been enough to satiate my cravings.
But I have learned that it's also a lesson in keeping things small and simple at first. Much kudos to those working a full time job and are able to get a side project up and running.
This blog also suffered as a result. I was afraid that the things I was learning outside of code might reveal too much about the internals of the startup I was with, so I just left nothing to chance. I simply fell out of the habit of blogging about what I've learned, and as a result I feel like my writing skills have deteriorated.
But now I've left the startup, moved to Mountain View, and I'm pursuing my own once again. It's not a secret what I'm working on, but I'd just rather talk about it in a separate post. I've also started exploring other technical topics as well, as I hinted in the last post about Potion. I'll start finishing up the backlogged technical posts.
So for those of you that still are subscribed, well, thanks for your faith. I'll be writing more, and I hope you'll be able to learn something from reading this blog as well. Have a great holiday!
For fun this morning, I cloned _why's potion and started going through the tutorial. After cloning it, I was able to compile it on my mac, and then I tried to run:
| | |
Unlike .bind(), only a single event can be bound in each call to the .live() method.
Because in 1960, the Bureau International des Poids et Mesures decided that the SI prefix G- meant 10^9.
But it means 2^30, really!
No it doesn't. Let's look at some examples:
Just a quick thought. It's pretty basic, but this was the first time I had a front-row seat demonstration of basic design principles and why they're suggested.
You can't really see it in the quotes, but if you follow the link, you'll see that the headings and text are the same size. Not only that, but the spacing between paragraphs is the same between headings and paragraphs.
That confused me and I had thought that the bolded statements was part of the text, and hence it was something the author was saying, rather than as intentioned, something we are readers would be saying as headings of different sections.
We differentiate importance and grouping by weight, size, color, and spacing. It takes a combination of these to discern what we're reading.
select DATE(created_at) as DateOnly, count(*)
from comments
where author_id = 877081418
group by DateOnly
order by DateOnly
Put simply, we enteredBigComputervianew, sothismeant “the new object.” On the other hand, we enteredthe_questionviadeep_thought, so while we’re executing that method,thismeans “whateverdeep_thoughtrefers to”.thisis not read from the scope chain as other variables are, but instead is reset on a context by context basis.
Javascript's scoping has been one of most confusing things about it, just as Ruby's metaclass and object model is the most confusing things about it. If you're looking to expand the horizon of what you understand about programming languages, it's worth it to figure out javascript scoping.
The paragraph gave a good way to think about it: this changes based on the object that calls the method. It only gets confusing when you start passing around functions and using callbacks, which is most of the power of functional programming.
As an example, here, I was using an anonymous function as a callback in the request() method. But it doesn't work!
So that's just one way to solve it. If you're using Prototype, you can also try using the bind() method. jQuery doesn't have an equivalent bind method, as hard as I looked for it at one time. I was just about to write it myself (as it's not too hard), but according to the a list apart article on Getting out of binding situations in javascript:
jQuery does not provide such a binding facility. The library’s philosophy favors closures over binding and forces users to jump through hoops (that is, manually combine lexical closures and
applyorcall, much as other libraries do internally) when they actually need to pass along a piece of code referring to “instance members.”
So while I use closures extensively in Ruby, I haven't had to explicitly think about the scope until I was using closures in Javascript. Huzzah. Hopefully, it'll prompt you to take a deeper look at Javascript.
Using this validation method in conjunction with ActiveRecord::Base#save does not guarantee the absence of duplicate record insertions, because uniqueness checks on the application level are inherently prone to race conditions.
This could even happen if you use transactions with the ‘serializable’ isolation level. There are several ways to get around this problem:
By locking the database table before validating, and unlocking it after saving. However, table locking is very expensive, and thus not recommended.
By locking a lock file before validating, and unlocking it after saving. This does not work if you‘ve scaled your Rails application across multiple web servers (because they cannot share lock files, or cannot do that efficiently), and thus not recommended.
Creating a unique index on the field, by using ActiveRecord::ConnectionAdapters::SchemaStatements#add_index. In the rare case that a race condition occurs, the database will guarantee the field‘s uniqueness.
"MethodNotAllowed: The specified method is not allowed against this resource." Error.
"If only I had ____ I would succeed."
These simple words will kill your dreams faster than anything else you could say or think. There are so many self-defeating thoughts that an entrepreneur can have, and they often take this very simple form.
Posted 3 hours ago
While Garry takes it in the direction of getting your hands dirty and building, and the recent HN discussion talking about whether one should sell or not, reading these compels me to take it in a different direction this morning before work--I'd like to speak a little about mental blocks.
There were many reasons why you'd want to sell your company. Your business deals with fads and the market will go away. You're done with this thing and want to move on. But there is a bad reason I want to focus on: "it'll give me freedom to do what I want". I think when people say this, they mean two different things: 1) if I have lots of money to take care of life's annoyances like bills and college tuition, then my mind will be free to work on anything 2) if I have lots of money, I can fund whatever I want to work on. The latter, I find to be an unconvincing reason.
My dad is retired. He talks about starting a foundation to help education in Taiwan, and seems rather passionate about it. He spends a lot of time watching and reading Taiwanese news. Given a chance, he'll talk your ear off about it. However, he says, "if only I had a million dollars", he could start his foundation. And the way he usually thinks of getting the million dollars is through the lotto. Now, my dad is no fool. He knows the odds. And I don't know if it's a generation gap in the way jokes are told, but if he's serious, it's a mental block that I see in some friends also. It's an excuse to do nothing because of the preceived notion that the external world hasn't given you permission.
By contrast, a couple years back Oprah had some special on TV about a new school she was building in South Africa. Though she put in a hefty sum, I was surprised to find out that she didn't put in all the money herself. She had other people help her with donations. That's why she had Nelson Mendela, Maria Carey, and others visit the school--to help donate. Even when she could pay for it all herself, she enlisted other people to help. In a more recent example, Breadpig and xkcd joined forces to put a school in Laos. They're putting in the work, yes, but as far as I can tell, it's none of their personal money.
Just because something takes a million dollars to do, doesn't mean it has to be your million.
Perhaps this is obvious to some of you, but I was a little bit surprised when I realized this. Growing up, I never thought about it too much, because in movies like Batman, Bruce Wayne funded his own crazy toys. So I naturally assumed that if you want to do huge things, you do it all with your own money. As a kid, I thought: If I wanted to build a Mechwarrior, I'd have to do it with my own money. If I wanted to build a loop-de-loop highway, I'd have to do it with my own money. If I wanted to build a giant chicken slingshot, I'd have to do with with my own money.
Of course, this comes with some amount of responsibility and constraint. Pissing away other peoples' millions is a sure way to get your legs broken, especially with money from a loan shark (or its million dollar equivalent). But I believe constraint in business and philantropy, as constraint in design, is a good thing to focus your efforts. Sometimes, personal money projects fail because they're not as readily subjected to market forces. A bad idea is kept afloat because there's a huge chunk of personal money that keeps getting dumped into it.
In the end, I just want to say, you have a choice. Don't let a little thing like not having a couple million stop you from doing what you want to do, as there's always more than one way to skin a cat. But if you want to build a pyramid for your burial site, then yes, please do that with your own money.
Of course csh is evil! That's nothing new. http://ooblick.com/text/CshProgrammingConsideredHarmful.html This works just fine with bash:
rab://tmp $ cat Rakefile
namespace :foo do
desc 'lol'
task :bar, :num do |t, args|
puts "num = #{args.num}"
end
end
rab://tmp $ rake foo:bar[123]
(in /private/tmp)
num = 123
Hey look. Arguments in Rake. I've been looking for this for a while now. No more using env variables.
(click image to enlarge)
This is one of the worst data visualizations I've seen. Problem is it looks pretty, so people send it around, but it's not very informational. Nor does it allow easy comparison of the data. First, it's not apparent that the light green and the dark green sections are the same thing until you realize it's an "O" from "Google", and actually adds no information. Second, what do the size of the circles represent? Is it combined daily spending or average daily spending per advertiser? It takes a while to find the circumferencial text, which you'd guess that it represents the amount of revenue from top N advertisers. Then the chart also mixes terminology. While spending by advertiser and revenue by google are the same thing, you need to do extra work to figure that out. Then, what the heck, the list of logos on the side is distracting. It's suppose to be the advertisers in the blue circle--the top 10 advertisers--but it sits firmly in the red section, which is the long tail of advertisers. Even more confusing, the $59,184,783 is red, but points to the blue list of logos. Lastly, the average daily spending is colored with the same position and weight as the combined daily spending, but it doesn't represent the size of the circles, which adds even more confusion.
The only thing they did right was to match the size of the circles with the amount of combined daily spending. Often times, people will draw these sorts of graphs using the diameter as the basis for comparison, which is misleading.
At first, I thought being able to return json as responses from the server was pretty neat, with rjs (now js.erb) files using render :update call in Rails. However, this often lead to some messy code by me and my colleagues. I would see lots of client side code in the application controller like:
Sometimes, you need to iterate over a number of jQuery elements. You pull something like this:
$.each($(".hello"), function() {
alert(this);
});
In this context, the "this" variable is actually not the jQuery objects. According to the docs: Whenever you use jQuery's each-method, the context of your callback is set to a DOM element. That is also the case for event handlers.
This is helpful when you want all the attributes of a particular DOM element. You can call attributes property on the "this" variable (this.attributes) inside of the each() method to get all attributes of each element with the class hello.
Lastly, if you have a jQuery element, you can get all attributes by:
$("#some_dom")[0].attributes
I finally found out how to do this, from the Rails Routing shortcut by David Black. In the Rails console, do this:
include ActionController::UrlWriter default_url_options[:host] = 'whatever'Then you can call your named route methods directly from the console.
This entry was posted on Tuesday, January 8th, 2008 at 1:58 pm and is filed under Programming, Ruby.You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
I've always just worked around this by trying it out in the templates. Should keep looking things up on google. I learn much more that way. Anyway, thought the rest of you should know also.
LoadError: Expected /[RAILS_ROOT]/vendor/plugins/delayed_job/lib/delayed_job.rb to define DelayedJob
The critical comment at that link is: "Prior to this revision, Rails would happily load files from Ruby’s standard lib via const_missing; you will now need to explicitly require such files."