14,003 karma · joined February 11, 2016
just another C hackerI had to add "-static" to LDFLAGS and "-lxcb -lXau -lXdmcp" to LDLIBS, for an increase in binary size from 1MB to 3MB. It's a plain X program, i guess if you use fancy toolkits it may be harder.
add -static to your link flags? Sometimes you need to fiddle a bit with the order of the libraries, but that's it.
In the ideal case, for maximum portability, i'd like to use the αpε format!
(I mean, from the distributing point of view. The sandboxing and resource management is a OS-thing that should be an orthogonal issue. Users must be able to sandbox programs that they don't trust, regardless to how they are packaged and distributed.)
This blatantly undemocratic and destructive behavior was of course duely punished by the (former) users of the site.
My 20 year-old .tex documents still compile today. Will the same happen with quarto? (or typst, for that matter?) The fact that they offer no packages in the debian standard distribution signals they have likely succumbed to the awful trend of version churning, where you need to use the last version of the software or else. Thus, probably, in 20 years my documents will be un-compilable. For legacy things like typeset documents, it's reasonable to prefer legacy solutions like latex.
Once quarto and typst have stabilized enough to appear in debian stable, I'll consider them as viable alternatives.
$ sudo apt install quarto
E: Unable to locate package quarto
yeah, hard passmaybe you meant associative? Floating point addition is commutative: a+b is always equal to b+a for any values of a and b. It is not associative, though: a+(b+c) is in general different to (a+b)+c, think what happens if a is tiny and b,c are huge, for example.
https://github.com/ColleagueRiley/RGFW.git
It was discussed recently around here: https://news.ycombinator.com/item?id=42217535
The macos backend is a neat hack, written in pure C.
mini_httpd -p 8080 # and no need to install a whole python interpreterAlso got this feeling on the first read... but now I remember them very fondly! I like to think that this trilogy happens in the same universe as Dune, being a prequel to the events of Dune. The homage to the Dune universe by the author is obvious (the names of the books, the notion of "other memories", etc). But many notions fit together, with some effort in your imagination. The second book of the trilogy provides a mechanism to explain the other memories in the form of nodal biology. The octopi ftl technique is reminiscent of the guild navigators. The third book hints subtly at a reason why the butlerian jihad could have happened.
I also love x87 registers, but they are becoming rarer these days.
assembler : everything is a word
C : everything is an array of bytes
fortran/APL/matlab/octave : everything is a multi-dimensional array of floats
lua : everything is a table
tcl : everything is a string
unix : everything is a file
In some of these languages there are other types, OK, but it helps to treat these objects as awkward deviations from the appropriate thing, and to feel a bit guilty when you use them (e.g., strings in fortran).
If you put the build files in a .builds/ folder at the root of your repository, they will be run upon each commit. Just like in github or gitlab. You are just not forced into this way of life.
If you prefer, you can store the build files separately, and run them independently of your commits. Moreover, the build files don't need to be associated to any repository, inside or outside sourcehut.
Just as a side note : when writing html5 by hand, you can use the full power of the language, most notably optional tags (no need to write html, body, etc) and auto-closing tags (no need to close p, li, td, etc). You may get something even crispier!
See for a reference the google html style guide : https://google.github.io/styleguide/htmlcssguide.html#Option...
And the official html5 reference for a complete list of optional tags : https://html.spec.whatwg.org/multipage/syntax.html#syntax-ta...
#define FPS 80
void plot_points(
float *o, // output raster array (w*h)
int w, // width of raster
int h, // height of raster
float *x, // input point coordinates (2*n)
int n // number of input points
)
{
// initialize the output raster
for (int i = 0; i < 2*w*h; i++)
o[i] = 0;
// accumulate the points that fall inside the raster
for (int i = 0; i < n; i++)
{
int p = x[2*i+0];
int q = x[2*i+1];
if (p >= 0 && p < w && q >= 0 && q < h)
o[w*q+p] += 1;
}
}
#include <stdlib.h>
int main(void)
{
int w = 1000;
int h = 1000;
int n = 3000000;
float *x = malloc(2*n*sizeof*x);
float *o = malloc(w*h*sizeof*o);
for (int i = 0; i < 2*n; i++)
x[i] = 1000*(rand()/(1.0+RAND_MAX));
for (int i = 0; i < FPS ; i++)
plot_points(o, w, h, x, n);
return 0;
}
// NOTE: if this program runs in less than 1 second, it means that it
// is faster than "FPS"In practice, stack sizes used to be quite limited and system-dependent. A modern linux system will give you several megabites of stack by default (128MB in my case, just checked in my linux mint 22 wilma). You can check it using "ulimit -all", and you can change it for your child processes using "ulimit -s SIZE_IN_KB". This is useful for your personal usage, but may pose problems when distributing your program, as you'll need to set the environment where your program runs, which may be difficult or impossible. There's no ergonomical way to do that from inside your C program, that I know of.
in my time, we used to know each other's IP addresses and just used netcat
> Do `#include <gc.h>` then just use `GC_malloc()` instead of `malloc()` and never free.
Even more liberating (and dangerous!): do not even malloc, just use variable length-arrays:
void f(float *y, float *x, int n)
{
float t[n]; // temporary array, destroyed at the end of scope
...
}
This style forces you to alloc the memory at the outermost scope where it is visible, which is a nice thing in itself (even if you use malloc).If you insist to fit the entire thing in memory, it may seem better to do so in the plain RAM, which nowadays is of humongous size even in "modest" systems.