HNHacker News
TopNewBestAskShowJobs

j4mie

5,979 karma · joined May 28, 2010

https://www.mtth.org
submissionscomments
j4mie··on A non-magical introduction to pip and virtualenv for Python beginners
Thanks, this is great advice. easy_install comes preinstalled on a Mac, which is where the confusion arose. Will update the article when I get a chance.
j4mie··on There's no magic: virtualenv edition
See also "Virtualenv's bin/activate is Doing It Wrong": https://gist.github.com/datagrok/2199506

The activate/deactivate magic is responsible for some real nastiness in deployment scripts, and total confusion for beginners who are thrown by the statefulness. Virtualenvwrapper makes the situation even worse by hiding the virtual environments away.

By far the easiest way to use virtualenv is to forget about activation completely, and directly reference the binary you want to use. For example, rather than typing:

    source env/bin/activate
    python myprogram.py
Just run

    env/bin/python myprogram.py
It's an extra few characters on every command, but it's worth it to totally remove the magic.
j4mie··on Why I switched to Pylons after using Django for six months
This article is two-and-a-half years old. Even if it were true at the time, things have moved on an awful lot since then.
j4mie··on Doctest.js: a humane Javascript test framework
This blog post is essential reading for Python developers who see doctest.js and think "ew, doctest": http://blog.ianbicking.org/2012/10/02/why-doctest-js-is-bett...
j4mie··on Advanced Flask Patterns
I love Flask for simple stuff, but I'm a little concerned that, as someone who considers himself a relatively advanced Python developer, I don't really understand quite a lot of this.

I have no doubt that if I dug into it then it would all make sense, but my first instinct is this: how much of this complexity (proxy objects to thread locals, context stacks etc) results from the fact that doing:

    from flask import request
is just a bad idea?

Perhaps things would be easier if instead of:

    from flask import request

    ...

    @app.route('/'):
    def index():
        return "Hello from %s" % request.args.get('name')
we did:

    @app.route('/'):
    def index(request):
        return "Hello from %s" % request.args.get('name')
I'm probably massively over-simplifying things, but the idea of magically importing state is the one aspect of Flask that always felt a bit odd to me.
j4mie··on NVD3.js: re-usable charts for d3.js
It would be great to actually figure out the steps required to make this happen. I'm not familiar with D3's code at all, but I know that it renders to SVG. Would it be possible to easily "plug in" Raphael's SVG/VML abstraction?
j4mie··on Building a higher-level query API: the right way to use Django's ORM
Your last example wouldn't work. Todo.high_priority() returns a plain QuerySet, which won't have your "incomplete" method (as that's defined on the Model class in your example).
j4mie··on Building a higher-level query API: the right way to use Django's ORM
> But my problem is that most people wouldn't even think of subclassing QuerySet.

I'd argue that's a documentation issue. QuerySet is Django's abstraction of a set of filterable database results. Keeping this conceptually separate from other parts of the ORM, such as the model class, is valuable IMO, and I'm not sure we gain much by trying to hide the details. One of the things I love about Django's philosophy is that it generally provides shortcuts that encapsulate common patterns without obscuring them.

There's a fine line between discussing the minutiae of API design and bikeshedding, and I think that anything Django can do to help here is valuable, so I won't push the issue any further. Let's pick it up again on the mailing list or Trac at an appropriate time.

j4mie··on Building a higher-level query API: the right way to use Django's ORM
Yep, and my criticism of your suggested approach wasn't intended to be particularly strong by any means. I could definitely be sold on the idea. It just felt like a workaround to a problem that could probably be solved in a nicer way.

I think my main objection is that these query methods should conceptually be on the QuerySet, and so defining them on the Manager (the "wrong place") and magically copying them to the QuerySet (the "right place") feels somehow worse than the opposite.

I appreciate that you raised the discussion on the mailing list, as it highlights the fact that this is a common problem in big Django codebases. Even pulling something like PassThroughManager into core might work (perhaps with a nicer "manager_with_queryset" API, as suggested by Aramgutang).

j4mie··on Ask HN: Who Is Hiring? (May 2012)
Brighton, UK - http://dabapps.com

DabApps is looking for a junior to mid-level software developer with minimum one year of experience. May suit graduate with internship or sandwich year experience.

DabApps is a growing company based in the centre of Brighton. We concentrate on web and mobile application development, and are passionate about producing high-quality work that we and our clients can be proud of. Our values are based on standards compliance and best practice and we are constantly working to improve and streamline our development process. We use open source technology wherever we can, and contribute back to the open source community as much as possible.

Below is a list of core technologies and skills we are looking for. We are not expecting any candidate to have experience or knowledge in all of these areas. What we are looking for is the ability and desire to learn in a self-motivated way to fill in the gaps in your knowledge as required.

Python, Django, Objective-C, JavaScript, HTML/CSS, Relational databases, Redis, MongoDB, CouchDB or other NoSQL databases, Solr, ElasticSearch or other search solutions, "Big Data", distributed systems, data analysis/indexing, Linux server administration, Mac or Linux desktop experience, User experience analysis and design, prototyping

See http://dabapps.com/careers/current-vacancies/2012-04-softwar... for full details.

j4mie··on The evolution of Lua
One thing I didn't like after a quick look at Lua is that all variables are global by default.

    j = 10         -- global variable
    local i = 1    -- local variable
( from http://www.lua.org/pil/4.2.html )

Same with functions. To declare a function that is restricted to the local scope, you must explicitly use "local":

    local f = function (...)
      ...
    end
Can any Lua aficionados explain why this is the case? Surely a better design would be for variables to have local scope by default, and to require an explicit "global" prefix to be globally visible? Does this ever cause problems in real-world code?
j4mie··on Rainbow.js - code syntax highlighting in 1.2kb
Ah, thanks, didn't spot that.
j4mie··on Rainbow.js - code syntax highlighting in 1.2kb
This looks like a very worthy replacement for http://code.google.com/p/google-code-prettify/

I can't see the license specified anywhere, any chance you could add a LICENSE file or similar?

j4mie··on Mezzanine, a Django powered CMS, reaches 1.0
Agree completely. This should be front-and-centre in the documentation. A CMS built on top of Django should, by default, be just another Django reusable app. It shouldn't take over your entire project.

The `mezzanine-project myproject` bootstrapping command should be just an optional shortcut for projects which are completely CMS-based. Which, in my experience, is the minority of projects.

j4mie··on Python URL manipulation made simple.
Similar project: https://github.com/zacharyvoase/urlobject

I built a template library for Django on top of it: https://github.com/j4mie/django-spurl

j4mie··on Calculize: A Mathematical Scripting Language
Impressive. They seem to have added operator overloading to CoffeeScript, among other things:

    # 1. Matrix multiplication

    m1 = matrix([1,  2,  5],
                [2, -1,  6],
                [5, 10, -1])

    m2 = matrix([2,   3,  1],
                [-3, -1, -3],
                [4,   9, -2])

    show m1 * m2
Not sure how this could be used for "serious" number crunching (as it runs in-browser) but I imagine it would be a fantastic teaching tool.
j4mie··on Embedly (YC W10) Raises Another $450K, Launches One API To Rule All Embeds
Is there such a thing as a library that abstracts away the differences between the JavaScript APIs of common embedded video players (YouTube, Vimeo, etc)?

This could be useful if I've embedded a player with embed.ly and then want to control it from elsewhere on the page (say, have a big "play" button somewhere).

j4mie··on Django REST framework with admin-style browseable self-documenting API
The main advantages are:

* automatic browsable self-documenting HTML output when you hit the API in a browser [1]

* the fact that django-rest-framework uses as much of Django 1.3's class-based view infrastructure as possible, and so fits better with the way Django works.

[1] example: http://api.django-rest-framework.org/

j4mie··on [dead]
I can't listen to jazz while coding. Jazz is foreground music. It's communicative: it grabs your attention and forces you to listen. It would be like trying to read a book and watch a movie at the same time.

For me it's ambient and/or electronic (particularly Brian Eno) or occasionally a bit of folk or indie.

j4mie··on Ruby or Python? Well, it depends...
I use bpython: http://bpython-interpreter.org/
j4mie··on W3C HTML5 Logo Unveiled
Nice article by Jeremy Keith on why this logo creates and propagates confusion between HTML5 and CSS3:

http://adactio.com/journal/4289/

j4mie··on Strict Mode Is Coming To Town
"The arguments pseudo array becomes a little bit more array-like in ES5. In strict mode, it loses its callee and caller properties."

Anyone know what replaces this?

How would I write this (stupid code that would eventually blow the stack) without arguments.callee?

    (function () {
        console.log("hello world");
        setTimeout(arguments.callee, 1000);
    })();
j4mie··on It's about time to start fighting against the Rails “magic” myth
... exactly.
j4mie··on It's about time to start fighting against the Rails “magic” myth
I think you might be fighting an uphill battle here.

Some developers prefer Python, some prefer Ruby. An individual developer might be able to reel off a list of reasons why one is better than the other, but in the end it comes down to something intangible and subjective - "Ruby just feels better" or "Python fits my brain better".

The concept of "magic" is very similar. What feels magical and opaque to one developer might be plain and obvious to another. When you ask what "magic" means, you'll get different answers from different people.

From my point of view (as a Python/Django developer), even the basic commands that Rails uses feel strange. Compare the very first line of code that you run in a Django project vs a Rails project:

    django-admin.py startproject mysite
with

    rails new blog  
The former says: "run the Python script called django-admin.py" (which immediately tells me that this is just a Python script that I could read, if I were so inclined) and pass the arguments "startproject" (which is a clear description of what is about to happen) and "mysite" (which is, fairly obviously, the name of the project to start). This reads like a sentence of the form 'use <tool> to perform <action> with arguments <arguments>'.

The latter says: "run the command rails" (what is this? A Ruby script? A bash script? A binary? Why is it called "rails" when the whole framework is called "Rails"?) and pass the arguments "new blog" (obviously this is creating something, but what? In most languages, "new" is a keyword that is usually used to create instances of classes - so is it creating an instance of something called "blog"? Does that mean that Rails knows what a "blog" is already?) To me - this is magic. Rails says "type this incantation and I'll do some stuff for you". Django says "here are some tools you can use to do stuff".

You might disagree with me entirely in this particular case - perhaps you find the Rails example clearer - which is fine. The point of this example is to say that framework and language preference is so intangible that the very first line of your documentation can sway someone's opinion either way. Instead of fighting against the "magic myth", you should just be trying to attract developers who like your particular brand of magic (or, alternatively, don't see your code as magic at all).

j4mie··on Artificial Intelligence Stack Overflow about to start
Of course - but one of the on-topic example questions is "How can I avoid premature convergence to a local optima on my genetic algorithm?". That has nothing to do with AI.
j4mie··on Artificial Intelligence Stack Overflow about to start
Why are genetic algorithms included? They are just a tool to explore multidimensional search spaces, and have nothing to do with AI unless they happen to be applied to an AI problem.

It would be nice if this was separated out into "old-fashioned" AI (data mining, statistical inference, machine learning, etc) and bio-inspired technologies (genetic algorithms, cellular automata, neural networks - although the latter may be a grey area).

Alternatively, a better name than "Artificial Intelligence" should have been used for the site. Probably too late now though..

j4mie··on Lanyrd feeds: never miss out on a conference
Lots of people are using Lanyrd for group meetings, social events, and all sorts of things that aren't conferences (eg http://lanyrd.com/2010/brightonpy-october/skgp/ ). It might be worth rethinking the tagline to make it more friendly to this kind of thing - assuming it's something you want to encourage.
j4mie··on ToroPHP - A Tiny PHP Framework
It's also worth taking a look at Slim:

http://www.slimframework.com/

j4mie··on ToroPHP - A Tiny PHP Framework
Try Idiorm (for basic ORM and query-building) and Paris (a simple Active Record implementation):

http://j4mie.github.com/idiormandparis/

j4mie··on The real reason (climate) scientists don't want to release their code
Actually, I have heard one good argument against open-sourcing scientific code [1]. It's not bullet-proof, and it won't apply in all situations, but I think there's a nugget of truth in there.

If I write a paper describing an algorithm (or process, or simulation, etc) and open source my code, someone attempting to reproduce and confirm my work is likely to take my code, run it, and (obviously) find that it agrees with my published results. No confirmation has actually taken place - errors in the code will only confirm errors in the results. Further work may then be based on this code, which will result in compound errors.

If, however, I carefully describe my algorithm and its purpose in my paper, but don't open source the code, anyone who wishes to reproduce my results will have to re-implement my code, based on my description. This is vastly more likely to highlight any bugs in my implementation and will therefore be more effective in confirming or disconfirming my findings.

I'm not sure yet what I think about this argument. It seems to only apply in certain domains and within a limited scope (what if the bug exists in my operating system? Or my math library?) but in relatively simple simulation models, it may have some validity.

What do you think?

[1] From Adrian Thompson, if you're interested: http://www.informatics.sussex.ac.uk/users/adrianth/ade.html

← PreviousPage 3 of 4Next →