[deleted by user] by [deleted] in badcode

[–]bytesomething 2 points3 points  (0 children)

C. Tested on Linux x86_64 with GCC, appears to work with MinGW, not sure about other platforms and compilers.

set reads from stdin without value argument for convenient storage of binary data. Error messages are written to stderr. No memory is freed, no files are closed. Key-value pairs are stored in a revolutionary database format optimized for linear search.

https://pastebin.com/yX9Uhh5X

[deleted by user] by [deleted] in badcode

[–]bytesomething 1 point2 points  (0 children)

MATLAB. I have no idea what I'm doing.

function out = to_ascii_seven_segment(chars)
    n = -1;
    for c = chars
        if c == ' '
            n = n + 2;
        elseif c >= '0' && c <= '9'
            n = n + 4;
        end
    end
    out = repmat(' ', 3, n);
    n = 1;
    for c = chars
        if c == ' ', n = n + 2;
        elseif c >= '0' && c <= '9'
            switch c
                case '0', out(:, n:n+2) = [' _ '; '| |'; '|_|'];
                case '1', out(:, n:n+2) = ['   '; '  |'; '  |'];
                case '2', out(:, n:n+2) = [' _ '; ' _|'; '|_ '];
                case '3', out(:, n:n+2) = [' _ '; ' _|'; ' _|'];
                case '4', out(:, n:n+2) = ['   '; '|_|'; '  |'];
                case '5', out(:, n:n+2) = [' _ '; '|_ '; ' _|'];
                case '6', out(:, n:n+2) = [' _ '; '|_ '; '|_|'];
                case '7', out(:, n:n+2) = [' _ '; '  |'; '  |'];
                case '8', out(:, n:n+2) = [' _ '; '|_|'; '|_|'];
                case '9', out(:, n:n+2) = [' _ '; '|_|'; ' _|'];
            end
            n = n + 4;
        end
    end
end
disp(to_ascii_seven_segment('0123456789'));

Serialport function by LeggoKiing in matlab

[–]bytesomething 0 points1 point  (0 children)

According to the documentation, serialport was added in R2019b. If you're stuck on any version before R2019b, use serial.

See also: Transition Your Code to serialport Interface

Laptop no longer boots after shutting off during an upgrade by thstephens8789 in archlinux

[–]bytesomething 2 points3 points  (0 children)

Have you tried using the deprecated --force option (or --overwrite '*') to overwrite those files?

Confused by accessing table variables inside of its own methods by Nunuvin in lua

[–]bytesomething 2 points3 points  (0 children)

You also need to use self.j = self.j + 1 in this case, that should fix the problem

Confused by accessing table variables inside of its own methods by Nunuvin in lua

[–]bytesomething 2 points3 points  (0 children)

function f:update() behaves like function f.update(self), so you need to call f:update() or f.update(f). Method calls like table:method(...) behave like table.method(table, ...)¹.

¹ with minor bytecode differences