Top
Best
New

Posted by retroplasma 1 day ago

"Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds(gist.github.com)
225 points | 103 commentspage 2
amelius 1 day ago|
Bonus points if you manage to record the Facebook tracking pixel.
zetanor 1 day ago|
The Meta EULA does NOT allow you to record their tracking pixel.
zuhsetaqi 1 day ago||
Does anyone know if this is fixed in macOS 27?
vardump 1 day ago||
Embedded Swift in a script. That seems like a useful concept for small scripts on macOS. I will definitely steal this idea.
thewebguyd 1 day ago|
Swift also has an interpreted mode, you can just

  #!/usr/bin/evn swift
  import Foundation
  print("Hello, world")
and chmod +x hello.swift and execute it.

Instead of doing swift in bash and calling swiftc, you can always shell out to Process() from inside a Swift script instead.

gorfian_robot 1 day ago||
reminds of a prank we pulled on a coworker back in the xterminal days. every time he hit a certain key it would invoke the 'melt' screensaver briefly. he was fairly unobservant though and we had to escalate to invoking it for 1s every minute before he finally noticed.

the follow on prank was having all the xterminals 'moo' whenever new code was deployed to prod.

ramses0 1 day ago|
That’s amazing! I am just imagining a room full of programmers with slightly divergent crontab start times all playing a "moo" sound effect, seemingly at random... not a bad ambient information radiator, actually!
swiftcoder 1 day ago||
Is the fix working because it forces the WindowServer to do a full composition of the cursor overlay, or just because it prevents the system from throttling down into a lower power mode?
inigyou 1 day ago||
What's with "guard !foo else return" instead of "if foo return", is that just how Swift is written?
NobodyNada 1 day ago||
guard is an inverted if statement, with the additional requirement that the branch must exit the parent scope. It's useful sometimes for readability, particularly for avoiding the "pyramid of doom" when you have a lot of preconditions that need to be checked:

    if fooOK 
        if barOK {
            if bazOK {
                // do something
            }
        }
    }
can be written as:

    guard fooOK else { return }
    guard barOK else { return }
    guard bazOK else { return }
    // do something
Obviously there are other options (like writing a negated if), but sometimes guard is more readable. It's a style thing.

The more important use case for guard is that 'guard let' statements can pattern-match and introduce bindings that are valid for the rest of the scope:

    guard let foo = someOptional else { return }
    print(foo);
This is useful enough that Rust copied it in the form of 'let ... else {}' statements (but did not bring over boolean guard statements).
silvestrov 1 day ago|||
Perl has the negated if statement:

    return unless fooOK;
    return unless barOK;
    return unless bazOK;
    # do something
adrian_b 1 day ago|||
Already in 1963, the language CPL introduced "unless ... do ...", besides the "if ... do ..." inherited from ALGOL 60. Perl has just followed the example of CPL and BCPL, decades later.

Using "if" or "unless", whichever is more appropriate, is far more readable than "guard".

Moreover, there are many languages where an assignment or an initialization can appear in any place where an expression can appear. Such general rules are always better than special rules like allowing new bindings in a "guard", but not in an "if". Pattern matching does not need any special syntax, it should work in the standard alternative program structure of that programming language, regardless whether it is called "select", "case" or "switch".

It always annoys me when the creators of new programming languages demonstrate amateurism, by inventing new worse alternatives than those that existed in various older programming language, already many decades ago.

There are plenty of new programming languages that claim to be better than C, which may be true, but they fail to match programming languages much older than C.

NobodyNada 1 day ago|||
> Using "if" or "unless", whichever is more appropriate, is far more readable than "guard".

How is a different (and longer) keyword "far more readable"? That's just a matter of preference and familiarity. The reason for choosing a different keyword is that it's not quite equivalent to an unless as the {} block must exit the surrounding scope. You read it like an assert statement with a custom handler.

> Moreover, there are many languages where an assignment or an initialization can appear in any place where an expression can appear. Such general rules are always better than special rules like allowing new bindings in a "guard", but not in an "if".

You can introduce bindings in an if too. The special thing about guard is that you can introduce a binding which is valid for the remainder of the scope outside the {} block (where the condition is true) but not inside (where the condition is false).

klausa 1 day ago|||
You’ve missed (or ignored) the “compiler enforces leaving the scope” part.
wwalexander 1 day ago|||
guard has two advantages: the compiler ensures that you exit the current scope if the condition does not hold (via return, break, continue, etc), and bindings established in the guard clause (e.g. let foo = optionalBar) remaining in scope after the guard block, rather than inside it like an if block.
mproud 1 day ago|
Is there a Radar open for this?
da_grift_shift 7 hours ago|
Exactly my question. 600 lines of Swift-in-shell-wrapper and Claude couldn't have run sysdiagnose and vibed out a quick report to throw into Feedback Assistant?
More comments...