News for hackers. Stuff that matters.

kerneloops

Re:Unconventional Ways to Cast in TypeScript on Saturday October 25, 2025 @12:07PM (#45704914)
Another one:

  const cast: <A, B> (a: A) => B = function <B> (): B {
    return arguments[0]
  }
  const n: string = cast(1)
Re:Tonal.js: Functional music theory lib on Thursday April 04, 2024 @03:13AM (#39927429)
See also: Well-typed music does not sound wrong (experience report), Haskell 2017

https://dl.acm.org/doi/10.1145/3122955.3122964

Re:Tell HN: Python's print function is thread-unsafe on Monday January 01, 2024 @03:35AM (#38830456)
A survey of some other languages:

C printf: MT-Safe locale.

C++ std::cout: safe, unless you call sync_with_stdio(false).

JVM System.out.println: safe in common JVMs.

C# Console.WriteLine: safe.

Go fmt.Printf: safe.

Rust println!: safe.

Ruby puts: safe.

So it seems that Python is the outlier here.

Tell HN: Python's print function is thread-unsafe

Some days ago I found that Python's print function is by default thread-unsafe, as the underlying sys.stdout is by default a TextIOWrapper, which is not thread safe. That means, for the code below from threading import Thread def target(x): for _ in range(100000): print(x) Thread(target=target, args=['a' * 10]).start() Thread(target=target, args=['b' * 10]).start() Python could...

( Read More... | 6 comments | 4 points | on HN )
The only problem to me is that the "official" Joplin Server is proprietary: https://github.com/laurent22/joplin/blob/dev/packages/server...
Re:Reverse Engineering TikTok's VM Obfuscation (Part 2) on Monday January 09, 2023 @09:07AM (#34310444)
> Using these accessors, the VMs become able to do anything that JS can do.

In fact the source language is likely to be JS itself; a JS-to-some-sort-of-vm-bytecode-to-JS compiler is made. I know that Tencent has a similar VM; an interesting aspect of that VM is that the instruction set is dependent on the code being compiled (and the opcodes are dynamically generated and shuffled when compiling), so unused instructions are not generated.

Re:Reverse Engineering TikTok's VM Obfuscation (Part 1) on Saturday December 24, 2022 @07:31AM (#34116231)
Another reason to use `void 0` is that "void 0" takes only 6 characters while "undefined" takes 9, saving some bandwidth. It is common practice for JavaScript minifiers to use this substitution.
Re:Samsung Recent Security Incident on Friday September 02, 2022 @08:46PM (#32697427)
I usually give them 1970/1/1 as my birthday. That's easier to remember, since password managers don't work well with date inputs sometimes.
Re:Falsehoods programmers believe about email on Thursday September 01, 2022 @08:07AM (#32675211)
Microsoft (at least used to) require account passwords to not include the part before @ in email addresses. My email address was a@(domain).net, and therefore I was prevented from using any password including the letter "a".
Re:How can you be fooled by the U+202E trick? (2013) on Wednesday February 16, 2022 @07:48AM (#30359320)
The character 囍 means "double happiness" literally, and is often used in wedding ceremonies among other places here in China. It is also included in the Xinhua dictionary, the semi-official dictionary in mainland China.
Re:The joy of building a ray tracer, for fun, in Rust on Tuesday January 04, 2022 @06:44AM (#29793788)
It's also a undergrad course lab here at SJTU, also in Rust: https://github.com/aik2mlj/raytracer-tutorial