HNHacker News
TopNewBestAskShowJobs

russellsprouts

289 karma · joined April 24, 2013

submissionscomments
russellsprouts··on Why Aren’t There More Asian Americans in Leadership Positions?
I think the point the gp was making is that 14% is over-representation given the demographics of the country at large. That doesn't discount that they are relatively under-represented given the demographics of the company.
russellsprouts··on Saving the Internet 2000TB a Day: Fixing Font Awesome’s Fonts
It can be used to subvert the same origin policy and content security policy.

If you see a script tag with the URL bank.com/evil.js, the browser shouldn't assume that the bank is actually hosting evil.js. Even if the hash matches, the content might not be there.

The bank might be using a content security policy to minimize the damage that an XSS attack can do. It only allows script tags from the same origin. However, now an attacker just needs to load evil.js with a particular hash into the cache, and they can create the illusion that the site is hosting it, without having to hack the server to do so.

russellsprouts··on Nestle says it will cut sugar in chocolate by 40%
I agree. I make 3 boxes at once. The box calls for 1.5 sticks of butter in that case, but I only use 1, and it comes out great.
russellsprouts··on Donald Trump is the president-elect of the U.S.
> Age shouldn't be the only criteria to allow someone in voting process.

https://en.wikipedia.org/wiki/Literacy_test

russellsprouts··on Ask HN: Is Bash for Windows good enough to replace a Linux/Mac terminal?
It is possible to run X programs with Bash on Windows. You need to run a Windows port of an X server, like Xming[1]. Even programs like Firefox work, though it's a bit laggy. It's good enough to run gvim, though.

[1]: https://sourceforge.net/projects/xming/

russellsprouts··on Ways to implement computer languages on 6502s (1994)
Coincidentally, I was just reading this the other day. I've been programming for the Nintendo NES. The most common high level language that people use for NES Homebrew development is C with cc65[1]. The output of the compiler is passable, but C is just not well suited to the 6502 processor. Eventually I'd like to write a compiler for a high level language that used these ideas.

[1] http://cc65.github.io/cc65

russellsprouts··on Restoring YC's Xerox Alto: how our boot disk was trashed with random data
The shift-xor "random" number generator described actually has an interesting property. The algorithm looks like this:

1. If the value is 0, output the magic number.

2. If the value has only its high bit set, output 0.

3. Otherwise, shift the value to the left

4. if there was an overflow (the high bit was 1 before the shift), xor the value by a magic constant.

For certain values of the magic constant, this has the property of generating every integer in the range exactly once.

russellsprouts··on Small Asteroid Is Earth's Constant Companion
I think the criteria is that it has cleared its orbit of similar sized bodies. Smaller bodies are OK. Pluto has several bodies of similar size in its neighborhood.
russellsprouts··on LÖVE 0.10 released with iOS and Android support
Yeah. I have used it with love. Moonscript is compiled beforehand to Lua, so it works the same. Lua's syntax is very nice, but the conciseness of Moonscript is nice for a lot of things.
russellsprouts··on There's Math.random(), and then there's Math.random()
That's true in general, but note that the runs should show up in 2 dimensions in the image. The second one appears clumpy, which exactly what it should look like. People tend to avoid runs, which would make it look more uniform. The first one has an obvious bias because it doesn't look the same in the x direction as in the y.
russellsprouts··on Ask HN: Do you attend Hackathons?
I'm a CS student, and I do attend hack-a-thons several times a year. My policy is to ignore the competitive aspect. I should feel successful no matter what the judges decide.

My mindset from the beginning is that I won't work on the project at all after the 24 hours allotted. It's a throw-away project. This is really freeing. You don't have to worry if the code is messy, or even if there is a fundamental problem with your idea (game mechanics, etc.)

My goal is to pick a new technology or library to learn and build something with it. Once, I decided I wanted to learn how to use OpenCV, so I made a little game that is controlled by facial tracking. Another time, I had just bought some USB Nintendo 64 controllers, and I wanted to make a game that used them, so me and some friends made a local multiplayer fighting game. (The projects almost inevitably end up as games). Another project we made a multiplayer game with WebSockets to fiddle with lag compensation and clock synchronization. I learned a ton of distributed systems stuff in that short time. Sometimes, the technical problems take all time, and the finished game just barely counts as playable. Getting OpenCV bindings working with Java took nearly 8 of the 24 hours. Another project, using WebRTC for a peer-to-peer multiplayer game, only came together in the last hour, and stretched the definition of game so much that we won a special award "for challenging perceptions of what games can be" :).

It doesn't really matter, because my goal isn't really to make a great game, it's to force myself out of my comfort zone to learn something new. The game is incidental, really. Sometimes, the judges are looking for something more polished, or more business oriented. That's OK -- the game isn't for those judges. I only invested 24 hours into it. However, I've been pretty lucky, so far -- most hack-a-thons I've been to really celebrate true hacks.

I think one thing organizers can do is emphasize the process of writing the code, rather than the result. Ask what challenges the teams faced, the hardest bug they fixed (or didn't :). Near the beginning, try to offer workshops on different technologies, so that people can branch out and try something new. You can also offer categories of judging -- if there is only one category, it's hard to decide between an awesome business idea with little technical innovation and an awesome technical achievement with little applicability. No matter which one you pick, someone will be disappointed. But if there's a category for best game, best presentation, best app, most innovative, best technical achievement, or whatever categories you pick, then everyone at the hack-a-thon can participate however they like best, and be recognized for it.

russellsprouts··on Nantucket: an accidental limerick detector
I made a bot that would fetch Twitter posts and re-tweet any it detected were 5-7-5 haiku. The syllable counter was just a series of regex replacements, loosely inspired by Metaphone, but it was about 95% accurate on my dictionary of 300,000 words.
russellsprouts··on How two bloggers re-purpose centuries-old recipes for modern cooks
I've made some of the recipes from this blog. The macaroni and cheese is particularly easy and tastes delicious.
russellsprouts··on Laplace’s Demon
This. Constraining the demon to two responses can't work. The demon needs to be able to give an answer with at least as much information as the entire universe's state -- not yes or no answers. The issue with the person only exists because the person's actions cannot be represented with a single bit of information. But the person cannot hope to outsmart the demon if it's response has more bits of information than the person can possibly respond with.
russellsprouts··on Lyra: An Interactive Visualization Design Environment
I work on this project.

One crucial thing to make the GUI simpler than code is direct manipulation. Working with a graphics program, like Inkscape, for example, is much easier for most graphics tasks than writing raw SVGs.

For most tasks in Lyra, you can simply drag-and-drop elements onto the visualization to make it respond the way you want. In advanced cases, true, you do have to navigate menus and buttons. For many of those cases, rather than writing raw D3 code, there's the Vega project. Vega is a declarative format for describing visualizations using a JSON format. Lyra generates Vega specifications for rendering, which can then be modified manually.

Vega: https://github.com/trifacta/vega

russellsprouts··on Segregation Now – separate and unequal education is coming back
However, these programs all happen within the same school. The trouble in the article is due to a single school with a wide range of options being split into several smaller schools, and the predominantly black school getting worse funding.

Programs such as Honors, AP, electives, etc., are the cheapest way for any student -- regardless of socio-economic background -- to receive high-quality education. Without those programs offered at public schools, I suspect that even more upper-middle class families would transfer to private schools or schools in the suburbs.

Consider sports electives: were they not offered at public schools, the only option would be club programs, often costing thousands per year. At a public school, somewhere around $50 is all that's needed for a year's worth of participation, with coaching that can be comparable to exclusive club teams, and scholarships available for even that amount.

edit: Also, because AP programs are standardized across the country, a student that passes AP Statistics at any school will have the same chance of getting college credit at any school that offers it. This levels the playing field a lot.

russellsprouts··on Lightbot: Kids learn programming concepts
Yeah, those features are very new. IIRC, they were introduced in the snapshots for 1.8, so they haven't even reached the stable version yet. (Minecraft 1.8 is nearing completion, after ~8 months of development).

Once 1.8 is officially released, someone could create educational adventure maps. I have played some 1.8 maps, and the new features can essentially make Minecraft into a game engine for voxel-based adventure games.

Here's an example from earlier in the 1.8 dev cycle -- there are even more features now. http://www.minecraftmaps.com/adventure-maps/mystery-of-the-t...

russellsprouts··on The Business of Fake Hollywood Money
It's important to note that this is not intended to be realistic. It's a parody of hacking sequences in TV and movies.
russellsprouts··on The 75-Year Saga Behind a Game That Teaches Preschoolers to Code
I know there are mods that incorporate turtle graphics-controlled agents for automation. Of course, there is also redstone automation, which is useful, but also much more complicated.

For slightly older kids, there's the Minecraft Pi edition.

russellsprouts··on Sodaconstructor: Interactive creations using masses and springs (2007)
When I was a kid, I was quite active in the soda race forums and the community there. In fact, my first open source project was a library for generating soda constructor models programmatically.

For example, it let you write text: http://sodaplay.com/creators/russellsprouts/items/font

Some good creators, I'm sure there are many more I'm forgetting:

http://sodaplay.com/creators/mmaarrkkuuss

http://sodaplay.com/creators/edlinfan

http://sodaplay.com/creators/grape

http://sodaplay.com/creators/jeckyll

http://sodaplay.com/creators/im_an_alien

http://sodaplay.com/creators/phider

http://sodaplay.com/creators/lectvay

http://warptera.com/

Many models are made up of motors with legs attached. Here are some interesting ones:

http://sodaplay.com/creators/motors

http://sodaplay.com/creators/other_motors

Also of interest, this paper empirically discovers the physics behind it: http://falcoprof.altervista.org/dispense/sodamathspaperfull....

russellsprouts··on Option and Null in Dynamic Languages
Yes, that's true. It does have drawbacks, but overall I think it is better than say, JavaScript. In JavaScript, a key can be not present in an object, be undefined, be null, be set to some other value, or be present in the prototype. The difference between these can cause very subtle bugs.

        //Let's define some object
        var obj = {a: true, b: true, c: true, d: true, hasOwnProperty: true}

        //Now let's make them falsy in different ways
        obj.a = undefined; //set to undefined
        obj.b = null; //set to null
        obj.c = false; //set to false
        delete obj.d; //delete key
        delete obj.hasOwnProperty //delete key, but present in prototype

        console.log(obj.a) //--> undefined
        console.log(obj.b) //--> null
        console.log(obj.c) //--> false
        console.log(obj.d) //--> undefined
        console.log(obj.hasOwnProperty) //--> [Function]

        console.log('a' in obj) //--> true
        console.log('b' in obj) //--> true
        console.log('c' in obj) //--> true
        console.log('d' in obj) //--> false
        console.log('hasOwnProperty' in obj) //--> true

        console.log(obj.a == null) //--> true
        console.log(obj.b == null) //--> true
        console.log(obj.c == null) //--> false
        console.log(obj.d == null) //--> true
        console.log(obj.hasOwnProperty == null) //--> false 

        for(var key in obj) {
          console.log(key) //--> prints a, b, c
        }
In Lua, the only data structure is a hashtable, which maps any non-nil value to any other non-nil value. It can also be set in the objects __index metamethod/table

        local tab = {a = true, b = true, c = true}
        
        -- by default there are none, but we can defined a fallback metatable similar to a prototype method like js's obj.prototype.hasOwnProperty

        setmetatable(tab, {__index={c='meta c', d='meta d'}})

        -- if it is important that a key is explicitly set to false, do so, otherwise simply remove it
        tab.a = false --set to false
        tab.b = nil --set to nil
        tab.c = nil --set to nil, present in fallback table
        tab.d = false --set to false, present in fallback table

        print(tab.a) --false
        print(tab.b) --nil
        print(tab.c) --meta c
        print(tab.d) --false
The rules for Lua are simple: Look for the key in the table, if it's not there, check the fallback defined in the metatable, if not, then return nil.

This is especially important in Lua, because any value can be a key, you would have to be sure to delete the key otherwise it could not be garbage collected. local tab1 = {1,2,3,4,5} local tab2 = {} tab2[tab1] = true for k,v in pairs(tab2) do tab[k] = nil end

If this worked like JavaScript, then tab2[tab1] would return nil, but tab1 could not be garbage collected until tab2 is. Because JavaScript objects can only have strings for keys, this is less of an issue.

russellsprouts··on JavaScript Modules
While a module system in JavaScript will be useful, this seems overly complicated.

I like Lua's approach to modules. In Lua, a file is basically equivalent to a function body. It accepts arguments and can return values. In JavaScript, this is not allowed.

In Lua, a function can accept multiple arguments in a tuple called `...`. Every file is implicitly a vararg function, so we can unpack the `...` to get arguments.

    > add.lua
      local a,b = ...
      return a + b 


    > file.lua
      local add = load 'add.lua'
      print(add(1,2)) --> 3
load takes a file path and returns that source file as a function. Most files ignore arguments, but they do return values.

    > add2.lua
      return function(a,b) return a + b end

    > file2.lua
      local add = require 'add'
      print(add(1,2))
`require` loads a source file, executes it, and returns the value that it returns. It is similar to `return load(fileName)()`, but it also has a search mechanism, and caches the result. So, the Lua equivalent of export default is simply returning a value at the end of a source file.

The named exports are also easy to replicate. You simply return an object with the keys you want.

    > math.lua
      return {
        add = function(a,b) return a + b end,
        sub = function(a,b) return a - b end
      }

    > other.lua
      local math = require 'math'
      local add, sub = math.add, math.sub
You can also have something similar to the `export function name(){}` declaration.

    > hello.lua
      local exports = {}

      function exports.hello()
        print "Hello World"
      end

      exports.VERSION = '0.0.1'

      return exports

    > file3.lua
      local hello = require'hello'.hello
      local version = require'hello'.VERSION

      hello() --> Hello World
In all, I think the Lua's require is a much cleaner way to implement modules. Unfortunately, it cannot handle circular references. It may be possible to add this feature using Lua's coroutines, however. I will have to research how it is handled in JavaScript to be sure.
russellsprouts··on Literally worse than EA
They have been delaying, but they have also hired several of the developers from CraftBukkit, which did create a plugin API for Minecraft. Their experience with CraftBukkit showed that they had created the API too soon. The code is messy and not amenable to mods.

The 1.8 update, currently in development, has added features, but it has mostly focused on refactoring and cleaning code. For example, they recently rewrote the entire block id system, removing numerical ids and instead using namespaced identifiers. This will allow mods to coexist rather than try to claim the same block ids.

russellsprouts··on Who am I: A mind reader (don't forget to view source)
Browsers lie in the computed CSS values. Regardless of whether you have visited the link or not, the computed style that JavaScript sees is always unvested.
russellsprouts··on Little-Known CSS Facts
If you really want to re-enable blink tags, drop this in. It's terrible code, but it is also tweetable. Besides, if you are using blink tags, who cares about a few global variables?

Example: http://ryanrussell.me/404

    setInterval('for(v="visibility",b=document.querySelectorAll("blink"),a=b.length;a--;)c=b[a].style,c[v]=c[v]?"":"hidden"',999)
russellsprouts··on JavaScript Promises in Wicked Detail
Promises are really Monads for asynchronous results.

A Monad kind of wraps a certain value. For example, we might have a Promise JSON from an API call. The bind method of a Monad (>>= in Haskell) takes a JSON Promise, and a function (JSON -> Promise b for some b), and returns a value of type Promise b. Promise.then is equivalent to bind.

In Haskell you might define them like this:

    data Promise msg val = Resolve val | Reject msg deriving Show

    instance Monad (Promise msg) where
        return = Resolve

        (>>=) :: Promise msg val -> (val -> Promise msg b) -> Promise msg b
        (Reject msg) >>= _ = Reject msg
        (Resolve val) >>= f = f val

They would be used like this

    newPromise = jsonPromise >>= transformJSON
In JavaScript, you would write

    var newPromise = jsonPromise.then(transformJSON)
However, the JavaScript case is slightly different. It is not as strict about types. It is possible (and typical) for transformJSON to return a bare type, rather than a Promise, while Haskell would require a Promise be returned every time. It treats an unwrapped value the same as an already fulfilled promise for that value. But automatically unboxing the promises that are returned gives them the full power of Monads.
russellsprouts··on Whither print.css? A Rallying Cry for a Web That’s Fit to Print (2013)
CSS3 has support for footnotes in the page module.

http://www.w3.org/TR/2011/WD-css3-gcpm-20111129/#footnotes

It adds a float: footnote; property. From reading that page, I believe this might work, once browser support catches up.

    a::after {
        float: footnote;
        content: attr(href) ' "' attr(title) '"';
    }
There are some other interesting additions:

    title { 
        display: none;
        string-set: title content();
    }
    
    @page { @top-left { content: string(title) }}
This will put the page title in the top left corner of the page margins.
russellsprouts··on Nerdsniping: A glimpse into a stubborn mind
Something like this could work, to some degree:

        a = {}
        a.valueOf = function() {
           var caller = arguments.callee.caller.toString();
           //parse the caller function, and return 
           //different values based on what comparison is being made. 
        }
But I think this is even worse than the getter on the global object.
russellsprouts··on The Hypocrisy Of Sam Yagan and OkCupid
But if you are checking if a person if qualified to be CEO, wouldn't their domain knowledge and ability to lead be better qualities to prioritize than their stance on gay marriage -- especially if their personal views have not been shown to affect how they intend to lead?
russellsprouts··on Mathematics: Why the brain sees maths as beauty
This essay really drove that point home for me:

http://www.maa.org/sites/default/files/pdf/devlin/LockhartsL...

← PreviousPage 2 of 5Next →