Better HN
topnewbestaskshowjobs
Log inSign up

tne

9 karma · joined Sep 15, 2014 (12y ago) · 8 submissions

Submissions

comment 8y ago · link · parent

  #include <stdlib.h>
  #include <stdio.h>
  
  static const char str[] = "fizzbuzz";
  
  static inline void out(int i, size_t offset, size_t sz)
  {
  	if (sz) {
  		fwrite(str + offset, sz, 1, stdout);
  	} else {
  		fprintf(stdout, "%d", i);
  	}
  	putchar('\n');
  }
  
  int main(void)
  {
  	for (int i = 1; i <= 100; i++) {
  		int a = i % 3 == 0;
  		int b = i % 5 == 0;
  		out(i, 4*((a^b)&b), 4*(a+b));
  	}
  	exit(0);
  }
There's a way to remove that conditional, too. Probably.

comment 9y ago · link · parent

There is no concept of an integer on an argument vector. Quoting in bash just escapes IFS characters (usually whitespace) to control whether to include them in a given argument on the vector, but these arguments (as passed to exec) are always character strings (with or without quoting).

comment 10y ago · link · parent

I would look at asm.js, do some tests with major browsers and beef it up. It would make it painful under user agents that don't JIT (or compile AOT) by leveraging asm.js conventions (many do though).

If the wasm effort works out (it's looking like it will), it would hopefully alleviate the issue you present entirely and make this solution viable in a very sane way.

comment 11y ago · link · parent

This is the approach taken by LY-Linux ("patch leap year"), although better implemented IMO. In fact, I typically only have to restart my servers once every 4 years (at most).

Look it up, it's awesome. (Please don't.)

comment 11y ago · link · parent

Related: Screeps https://screeps.com/

comment 11y ago · link · parent

AFAICT both Haxe and AS3 consistently put types on the right, including argument declarations. Other languages consistently put it on the left. Most languages make a choice like that; PHP mixes things up a bit.

But then, it wouldn't be PHP if it was too consistent ;).

comment 11y ago · link · parent

Same here, except I typically use $(!!) to re-run the previous command. I find it faster than command-line editing.

    $ find . -name "*blarg*.cpp"
    $ grep -i "blooey" $(!!)
    $ vim $(!! -l)
Granted, you can only append new arguments and using the other ! commands will often be less practical than editing. Still, it's amazing how frequently this is sufficient.

I've always thought it'd be nice if there was a `set` option or something similar that would make bash record command lines and cache output automatically in implicit variables, so that it doesn't re-run the commands. The semantics are definitely different and you wouldn't want this enabled at all times, but for certain kinds of sessions it would be very handy.

EDIT: lazyjones beat me to it.

8.

Living Standards: “Who Needs IANA?”(masinter.blogspot.com ↗)

1 points · by tne · 12y ago · discuss