HNHacker News
TopNewBestAskShowJobs

ahoge

1,026 karma · joined December 11, 2011

submissionscomments
ahoge··on Experimental New Directions for Javascript
This function is fully typed: http://i.imgur.com/xHWlJVn.png

Types are optional and they can be also inferred.

ahoge··on Experimental New Directions for Javascript
Please don't dismiss optional typing without trying it first.

Even if you don't add any type annotations yourself, you'll still benefit from the annotated libraries and from type inference.

To get almost all of the tooling benefits, you only have to annotate arguments and the return value. That's it. Inside your functions you generally can omit them because there are enough types floating around. Literals have a type and if you call an annotated function, you also know what type you get back.

E.g. this function is fully typed (none of the variables is purple):

http://i.imgur.com/xHWlJVn.png

ahoge··on Replace CoffeeScript with ES6
> why not just # like everyone else?

You mean like CS? '#' actually isn't a very popular choice for this.

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

ahoge··on Show HN: Using SVG to Shrink Your PNGs
The project itself is done. It does everything it's supposed to do. Some things could be done a bit more efficiently, but it seems to be fast enough. The readme is a bit outdated, but the usage bit (which is printed if you run it without arguments) covers everything.

I kinda lost interest in this project, because, back then, it actually didn't work. The SVG spec had to be fixed first and Chrome didn't even display those images at all due to a bug.

Basically, the problem with the spec was that it required the masks to use some nonsensical color space. Half of the implementations didn't, because it didn't make any sense and because the wording was extremely confusing.

Anyhow, the spec got changed and browsers started to implement this newer version of the spec. Nowadays, it actually does work.

Well, that's basically the whole story. That's why there isn't an article which promotes it. There were showstoppers which made it completely unusable.

ahoge··on Show HN: Using SVG to Shrink Your PNGs
Flash actually supports JPEG with lossless alpha (DefineBitsJPEG3). Just clipping a JPEG does of course also work.
ahoge··on Show HN: Using SVG to Shrink Your PNGs
There is a tool for that:

https://github.com/mahonnaise/svgjng/

    java -jar svgjng.jar <rgba image> <svgz file name> [color quality] [alpha quality]
It tries PNG and JPEG for RGB and alpha and then uses whichever ended up smaller.

Gallery: http://kaioa.com/b/1102/svgjng/index.html

"SVGZ (auto)" means default parameters. I.e. just:

    java -jar svgjng.jar foo.png foo.svgz
ahoge··on Google discloses another Windows security issue after deadline exceeded
If that would be the case then we would have another term for the thing I just described, because that's the worst case scenario.

Anyhow, the Wikipedia article disagrees with you, too. Got any sources for your definition?

ahoge··on Google discloses another Windows security issue after deadline exceeded
http://en.wikipedia.org/wiki/Zero-day_attack

> It is called a "zero-day" because the programmer has had zero days to fix the flaw

ahoge··on Google discloses another Windows security issue after deadline exceeded
> [...] and discloses a zero-day.

90-day, you mean. It's only zero-day if they had zero days to come up with a solution. That's what "zero-day" means.

ahoge··on Full-fledged FPS in WebGL
I did. I dislike bob/pitch/roll in general. I appreciate that they added a checkbox for that. Also, having a FOV slider is great, too.

I couldn't set the mouse sensitivity high enough though.

ahoge··on Full-fledged FPS in WebGL
> Doom-like movement and shooting mechanics

Doom controls a lot better. I played some Brutal Doom just an hour ago. In Doom, there is some inertia. You accelerate and there is some friction. In this game, movement is a binary on/off thing. The bobbing is also very jarring.

ahoge··on Full-fledged FPS in WebGL
You need hardware and drivers which support WebGL. With Chrome, open "chrome://gpu/" to get some rudimentary status report. Also, try updating your drivers. The one you're currently using might be blacklisted.
ahoge··on Is JavaScript getting worse?
>Classes. Whoop-dee-freakin’-doo.

There are dozens of ways to do classes/inheritance. Standardizing this means better tooling, documentation, and interoperability.

>Default parameters. By itself, this is another “so what” feature.

It's extremely useful in conjunction with named parameters. Named parameters are so much better than "option" objects.

If it's right in the function's signature, you can see right away how this thing is supposed to be used. Since it's declarative, it can be also picked up by your editor, too.

>let considered harmful

No, it's not. It makes variable declaration work like everywhere else. Function scope is the super weird anomaly.

ahoge··on Why is Golang popular in China?
Dart doesn't, surprisingly. I don't really mind though. It just means that I can't use non-English identifiers which I shouldn't be using anyways.

Non-English identifiers can be quite troublesome in international projects. Even if your project currently isn't, it might be in a few years. It's a maintenance nightmare waiting to happen.

ahoge··on MongoDB Is Raising Another $100M
Postgres also got hstore (key-value) and arrays. So, if you only need a little bit of flexibility on top, you can have that, too.
ahoge··on MongoDB Is Raising Another $100M
CouchDB just isn't very nice to use. Compared to MongoDB or RethinkDB, it really isn't any fun. You can't do ad-hoc queries and it doesn't give you the tools to properly write/test your map/reduce/rereduce functions. I still don't know how trying the rereduce step is supposed to work.

To make matters worse, the used JS engine is fairly old and the exceedingly wordy documentation is kinda hard to follow.

I'm a lot happier with RethinkDB.

ahoge··on Wikipedia on HHVM
Thanks. Graphs are so much better without "fine print".
ahoge··on Wikipedia on HHVM
The y-axis of the first graph should start at 0. Being more than twice as fast is quite a lot. There is no need for cheap tricks.

If you aren't visualizing tiny deltas, don't truncate the y-axis. It's misleading.

ahoge··on Flexbugs: a list of flexbox bugs and cross-browser solutions to them
> I can't believe that flexbox is the best thing they could come up with.

Flexbox is pretty damn good:

http://philipwalton.github.io/solved-by-flexbox/

Also, in case you didn't know, there is also Grid Layout:

http://gridbyexample.com/

Flexbox is 1D, Grid Layout is 2D.

ahoge··on BLOKK – A font for clients who don't understand lorem ipsum
Yea, Unicode got that covered:

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

Related:

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

ahoge··on ECMAScript 6: new OOP features besides classes
> Are you supposed to only use let now?

Yes, if you can use `let`, there is no reason whatsoever to use `var` ever again.

If you want the `var` behavior, just put your declaration at the very top of the innermost function. With most code conventions, that's where you'd put a `var` declaration anyways.

For what it's worth, Crockford also recommended to use `let` exclusively as soon as you can.

ahoge··on MozJPEG 3.0
Why not use it for canvas.toDataURL?
ahoge··on MozJPEG 3.0
That's a 1bit scan saved as JPEG. This should have been saved as 1bit PNG.

http://i.imgur.com/2wAcBdL.png (23.43 KB)

For nicer looking images, scan as grayscale and then use Photoshop's Image -> Adjustments -> Curves to turn everything almost-white to white and everything almost-black to black:

http://i.imgur.com/ktj8WkE.png

Alternatively, do a high-DPI 1bit scan, convert the document to 8bit, and then scale it down.

E.g. when you go from 1600 DPI to 100 DPI, you have 16x16 1bit pixels per 8bit pixel. The result will look smooth and crispy.

ahoge··on Self-Hosting Google Web Fonts
> they don't offer download links

1. Add fonts to your collection.

2. Click the download button in the upper right corner.

ahoge··on You Don't Need JQuery
With spread and fat arrows:

    [...document.querySelectorAll('.foo')].forEach(node => node.classList.remove('bold'));
ahoge··on Skeleton 2.0 CSS Framework
You can do quite a bit with naming conventions. Classes are case sensitive. So, you can for example use uppercase camel case for your building blocks and lowercase camel case for the things they are made of.

There are also dashes and underscores. I use underscores for "modifiers". That is, classes which modify the look of some building block. E.g. "Button" is the usual one and "Button _large" is a large one.

Custom elements will hopefully help to make this kind of structure a bit more popular. Right now they still have a few rough edges though.

ahoge··on “This” in JavaScript
It's clamped to 4. You can't go lower than that.

There is `setImmediate` for making something run the very next cycle. However, only IE10+ supports it and the other browser vendors are against it. You can use abuse `postMessage` to get a similar effect.

ahoge··on BPG Image format
http://httparchive.org/interesting.php
ahoge··on Introducing Spider 0.1
It lets you paste some code and hit auto-format.

I'm actually kinda serious. Moving pieces of Python code around is unnecessarily error-prone. I don't consider this to be a good tradeoff.

ahoge··on GoPro Developing Line of Consumer Drones
They are drones though. A drone is just an unmanned air vehicle (UAV).

The armed ones are in a subcategory called "unmanned combat aerial vehicle" (UCAV) or just "combat drone".

← PreviousPage 5 of 16Next →