HNHacker News
TopNewBestAskShowJobs

someone13

1,122 karma · joined May 30, 2011

submissionscomments
someone13··on Choosing the Right JavaScript Framework
If you don't mind sharing, have you done any research on data layers for React? From what I can see, there seems to be three major schools of thought: the Flux architecture, using Backbone's models, or just writing something custom.
someone13··on Option Monads in Rust
Do you have the source released somewhere? I'm interested in Rust but haven't really written anything large - I would find it interesting to see what a large project looks like, especially the kinds of problems that come up (like you mentioned).
someone13··on A 30-minute Introduction to Rust
I'd love to hear about how GCs can be useful for hard real-time systems! I was always under the impression that you needed to avoid that kind of stuff, so any links / information you have would be really interesting.
someone13··on Why Go Is Not Good
Since none of your examples are actually doing the same thing, I'm not sure what you're trying to say here. That being said, I've reformatted the code from the original post below (presented without comment):

-----

Haskell (with third party library)

http://snapframework.com/docs/tutorials/snap-api

    main :: IO ()
    main = quickHttpServe site
    
    site :: Snap ()
    site =
        ifTop (writeBS "hello world") <|>
        route [ ("foo", writeBS "bar")
              , ("echo/:echoparam", echoHandler)
              ] <|>
        dir "static" (serveDirectory ".")
    
    echoHandler :: Snap ()
    echoHandler = do
        param <- getParam "echoparam"
        maybe (writeBS "must specify echo/param in URL")
              writeBS param

Rust (with third party library)

https://github.com/chris-morgan/rust-http/blob/master/src/ex...

    //! A very simple HTTP server which responds with the plain text "Hello, World!" to every request.
    
    #![crate_id = "hello_world"]
    
    extern crate time;
    extern crate http;
    
    use std::io::net::ip::{SocketAddr, Ipv4Addr};
    use std::io::Writer;
    use http::server::{Config, Server, Request, ResponseWriter};
    use http::headers::content_type::MediaType;
    
    #[deriving(Clone)]
    struct HelloWorldServer;
    
    impl Server for HelloWorldServer { 
        fn get_config(&self) -> Config { 
            Config { 
                bind_address: SocketAddr {
                    ip: Ipv4Addr(127, 0, 0, 1),
                    port: 8001
                }
            }
        }
    
        fn handle_request(&self, _r: Request, w: &mut ResponseWriter) {
            w.headers.date = Some(time::now_utc());
            w.headers.content_length = Some(14);
            w.headers.content_type = Some(MediaType {
                type_: String::from_str("text"),
                subtype: String::from_str("plain"),
                parameters: vec!((String::from_str("charset"), String::from_str("UTF-8")))
            });
            w.headers.server = Some(String::from_str("Example"));
    
            w.write(b"Hello, World!\n").unwrap();
        }
    
    }
    
    fn main() {
        HelloWorldServer.serve_forever();
    }

Go (native)

    package main
    
    import (
        "fmt"
        "net/http"
    )
    
    func handler(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
    }
    
    func main() {
        http.HandleFunc("/", handler)
        http.ListenAndServe(":8080", nil)
    }
    
Yeah, ok.
someone13··on Piston, a prototype video game engine written in Rust
irc.mozilla.org
someone13··on Show HN: Untrusted, a JavaScript adventure game you play by modifying its source
Thanks for the game! Credits don't load on the mirror - I get a 404 on the AJAX call.
someone13··on Alleged Mt.Gox code leaked on IRC node by Russian Hacker
Not to say whether PHP is in fact a good idea or not, but at least in a statically-compiled language, once you've got a "working binary", however you accomplish that, it will presumably continue to function that same way indefinitely. Obviously barring OS-level problems, of course :)
someone13··on There will be blood - Photo Analysis
Regardless of all the criticism of the analysis, or whether the analysis is "worth it": this post is a really interesting look into how someone that does photographic forensics professionally operates. I thought it was pretty nifty :)
someone13··on I challenge you to remove the gray ad using Adblock
I took yours and lukegb's a bit further - thanks for the inspiration. Probably overkill, though :-P

    var removeImageByHash = function() {
        var bad = [525994816];
        var canvas = document.createElement('canvas');
        var ctx = canvas.getContext("2d");
        var imgs = document.querySelectorAll('img');

        for( var idx = 0; idx < imgs.length; idx++ ) {
            var el = imgs[idx];

            canvas.width = el.width;
            canvas.height = el.height;
            ctx.drawImage(el, 0, 0, el.width, el.height);

            var hash = 0;
            for( var i = 0; i < el.width; i++ ) {
                for( var j = 0; j < el.height; j++ ) {
                    var pixel = ctx.getImageData(1, 1, 1, 1);

                    hash = ((hash << 5) - hash) + pixel.data[0];
                    hash |= 0;
                    hash = ((hash << 5) - hash) + pixel.data[1];
                    hash |= 0;
                    hash = ((hash << 5) - hash) + pixel.data[2];
                    hash |= 0;
                }
            }

            var found = false;
            for( var i = 0; i < bad.length; i++ ) {
                if( bad[i] === hash ) {
                    found = true;
                    break;
                }
            }

            if( found ) {
                var hidden = document.createElement('div');
                hidden.style.display = 'none';
                hidden.style.width = 0;
                hidden.style.height = 0;

                document.body.appendChild(hidden);
                hidden.appendChild(el.parentNode.removeChild(el));
            }

            console.log(idx + ": " + hash);
        }
      };
someone13··on I challenge you to remove the gray ad using Adblock
Probably trivial to fix, but:

    var found = false;
    $('img').each(function(i, elem) {
        var e = $(elem);
        if( e.attr('src') !== '' && !found ) {
            e.attr("style","opacity:0.0;");
            found = true;
        }
    });
someone13··on Compiling to Lua
Check out Luv - an attempt to use Lua's coroutines to do green threads/fibers, integrated with libuv.

https://github.com/richardhundt/luv

someone13··on Introducing Stripe UK
Actually, AFAIK, Stripe will export your card data to any other provider, if you ask them to.
someone13··on Super Mario World "Completed" in Under 3 Minutes by Corrupting the RAM
bsnes is now distributed with / renamed to a project called "higan", which is a multi-system emulator. See:

http://byuu.org/higan/

someone13··on How To Get Banned From PyCon
If I can put my 2c in here...

I think that one of the major issues facing conferences is the distinction between professionalism and private life. The way one behaves with good friends is very distinct from how one behaves in a group of strangers, which is distinct from how one behaves with your co-workers or other professional relationships. I think that the mixed culture of a conference might exacerbate this problem: despite the fact that you're attending with friends, and perhaps even going out for drinks, it's not the same as being in a solely social setting.

If I'm with my friends, I know what jokes are appropriate, and which ones aren't - I've had the experience to do that. On the other hand, if I'm at a conference, someone nearby could have a bad reaction to a comment that my friends wouldn't react to - people are different, and an "innocent dick joke" to a friend could really bother someone else.

I don't pretend to say that this is the sole problem, or even a real solution, but I think it might be worth recognizing.

someone13··on Start testing your app with Casper.js
Something else worth noting: the most recent release of PhantomJS actually has an implementation of the Selenium WebDriver protocol, so you can use that, if you wish:

http://phantomjs.org/release-1.8.html

someone13··on Introducing Braintree.js
I can't speak to anything like IP or user agent, but they're not doing anything with cookies. You can put their JS code:

https://js.stripe.com/v1/

Into a JavaScript beautifier:

http://jsbeautifier.org/

And see that there's no mention of cookies at all, and, their server won't see cookies from another domain.

someone13··on Could the eagles have flown Frodo into Mordor? (2000)
Warning: most of this site is NSFW.
someone13··on Why Discourse uses Ember.js
Small nit: the link to the ember.js guides actually goes to the AngularJS guides.
someone13··on Python Shortcuts for the Python Beginner
Another method that I find isn't used enough: dict.setdefault. Instead of doing this:

    if 'key' in d:
        val = d['key']
    else:
        val = d['key'] = 'some default value'
You can do this:

    val = d.setdefault('key', 'some default value')
This is super-useful for configuration in frameworks, for example - it's a one-liner to set a default config value if the user didn't provide one.
someone13··on Stripe Checkout
I believe the reason for this is that it's one of the simplest card numbers that passes the Luhn check:

http://en.wikipedia.org/wiki/Luhn_algorithm

someone13··on Go: a nice language with an annoying personality
One thing I always thought would be interesting to do is make it such that the "enforced stylistic" bits of a language were tied to the optimization settings. For example, make warnings not halt the compile on the compiler's equivalent for -O0, and then on any higher optimization setting, they become compiler errors that can't be turned off. It doesn't completely prevent people from doing stupid things (e.g. deploying a debug binary to production), but it's, in my opinion, a good way of solving exactly the problem mentioned here.
someone13··on A new UI annoyance
I clicked "Open link in Incognito Window" on Chrome, and it worked for me without signing in, FWIW.
someone13··on 2012 Personal Annual Report
Here's a quick script I whipped up. No warranty, etc. Also, you need OpenCV installed.

https://gist.github.com/4476997

OpenCV: http://opencv.willowgarage.com/wiki/

someone13··on Ask HN: So, what is your problem?
Actually, you can do this with Stripe Connect [1]. The end-user signs up with a Stripe account, you get an OAuth key, and can make charges on their account. You can also collect fees on top of any payments [2].

[1]: https://stripe.com/docs/connect [2]: https://stripe.com/docs/connect/collecting-fees

someone13··on LuaJit 2.0 is out
Yes, totally possible! For example, see MoonScript, a CoffeeScript-like language that compiles to Lua:

http://moonscript.org/

someone13··on How to get your IP unbanned on HN
Do you have a rough set of guidelines for how fast we should request from HN? For a side project, I was thinking of writing something that scraped the HN frontpage and all the associated comment threads every 10 minutes or so, and I'd rather not cause performance issues or get banned. I'd be happy to rate-limit requests to whatever is convenient.
someone13··on [dead]
HN has a built-in polling feature. I don't know what the requirements for using it are (I have ~600 karma and can't seem to create it), but I suspect that using that would be a better idea than two solutions.
someone13··on Introduction to Heroku Buildpacks
Maybe someone here will know this - is there anything out there that lets one run a Heroku buildpack on a server you control? They seem like really elegant solutions to the problem of shipping around dependencies, and I'd like to be able to use them on my own hardware...
someone13··on Stolen Money on Gittip, Part 1
Despite the downvotes, this guy is correct - Vietnam is probably the country with the most incidences of credit card fraud.
someone13··on Warning to YC applicants: We're going to restart HN tonight
Out of sheer curiosity, is the restart a manual thing, or is it just on a cronjob? I'm thinking by the wording of the OP, it's done manually, but I'm still going to ask :-)
← PreviousPage 2 of 7Next →