Better HN
topnewbestaskshowjobs
Log inSign up

jhawthorn

43 karma · joined Jul 27, 2011 (15y ago) · 17 submissions

http://www.johnhawthorn.com
Submissions

1.

Writing an AI for a turn-based game(johnhawthorn.com ↗)

3 points · by jhawthorn · 8y ago · discuss

comment 8y ago · link · parent

You would use the LDR instruction to load the word from RAM. So just one instruction, but with some slower memory access.

When writing ARM assembly, the assembler (at least the ones I've seen) abstract this detail away from you.

You can use

    ldr    r0, =0xff000000
and the assembler will emit a MOV if it can, and if it can't it will put the value somewhere in RAM and use LDR to load it up.

ARM is fun.

3.

Show HN: Convert curl commands to Ruby's net/http(jhawthorn.github.io ↗)

12 points · by jhawthorn · 10y ago · discuss

comment 12y ago · link · parent

I made a small rails app which presents reddit AMAs nicely

http://ama.hawth.ca/1xj56q

Here's the source https://github.com/jhawthorn/riama

comment 13y ago · link · parent

The f suffix has been removed in favour of the existing "foo".freeze (which is now recognized and optimized in the parser)

https://www.ruby-lang.org/en/news/2013/11/22/ruby-2-1-0-prev...

https://bugs.ruby-lang.org/issues/9042

comment 13y ago · link · parent

I would argue the opposite: you should always use rvm (or similar) in production. I've done this for many projects, it's great to have the same ruby version and patchset in development, CI, staging, and production. rvm is also well supported in capistrano and jenkins.

comment 13y ago · link · parent

Not saying python 3 should have been compatible with 2. Just that this was not an apt comparison.

comment 13y ago · link · parent

I would guess error handing (freeing memory, closing fd's). A goto lets you avoid deeply nested if statements.

comment 13y ago · link · parent

Difference being that new versions of java, windows, c++ compilers work with the existing software.

comment 13y ago · link · parent

I wouldn't use god. It's had issues crashing or misbehaving in the past. I've found monit very stable if a little awkward to configure correctly.

Today I would use systemd with monit for additional monitoring. systemd ensures that the same environment is used regardless of how it is invoked, and the units are extremely simple. Monit can ensure a running server is behaving (memory limits, CPU limits, testing HTTP) and rely on systemctl for restarting processes.

comment 13y ago · link · parent

These are clearly slides, meant to be fullscreen on a projector. Up/Down, Left/Right, PgUp/PgDown all work, much like they would in powerpoint. I'm a little baffled by this threads hostility towards the lack of a friendlier design.

comment 13y ago · link · parent

You will not run into this problem. Linux is almost always used for production servers and is popular for development as well.

comment 14y ago · link · parent

Similar is https://www.pwdhash.com/

comment 14y ago · link · parent

I've been using fullwidth characters. Due to their simplicity to convert to and read. This page of course has the advantage of more variety in characters.

Fullwidth conversion code in ruby:

  "string".tr(' !-~', "\u3000" + (0xFF01...0xFF5f).to_a.pack('U*'))

comment 14y ago · link · parent

Oh, no! Missed noticing my first link from HN for a few days. Hopefully I can clarify some of this.

First, this is in no way faster than cuSPARSE or cusp. I wrote this for an originally for a school assignment (hence older cuda version) and was hoping to convey what I had learned my first time using cuda.

The size of the shared memory is so the reduction has no buffer overflow without using conditionals. However I am using more than needed, it should be set to 32+16. I don't expect this to affect performance as the kernel already reaches 100% theoretical occupancy.

Could you explain the desire for more threads/blocks per row? I can't immediately think of one, having more additions per thread sounds good so long as all are running.

Thanks very much for the read and the reply!

comment 15y ago · link · parent

Other than recommending #map, #select, et al, the rest is poor advice. Consider the following recommendation

  input.inject({}) do |hash, item|
    hash.merge(item => process(item))
  end
Far, far slower, more memory intensive (big deal, given ruby's gc), and uglyer than the sane (and commonly accepted)

  Hash[input.map do |item|
    [item, process(item)]
  end]