ArchieMaclean
ArchieMaclean on Hacker News
My take on the prime example:
import itertools
def generate_n_primes(n):
"""
Generate n prime numbers using a modified Sieve of Eratosthenes.
The algorithm keeps track of a list of primes found so far,
and a corresponding list of 'multiples', where multiples[i] is a multiple of primes[i],
(multiples[i] is initially set to be primes[i]**2, see the optimisations section below).
The main loop iterates over every integer k until enough primes have been found,
with the following steps:
- For each prime found so far
- While the corresponding multiple is smaller than k, increase it by steps of the prime
- If the multiple is now the same as k, then k is divisible by the prime -
hence k is composite, ignore it.
- If, for EVERY prime, the multiple is greater than k, then k isn't divisible by any
of the primes found so far. Hence we can add it to the prime list and multiple list!
There are a few optimisations that can be done:
- We can insert 2 into primes at the start, and only iterate over every odd k from there on
- When we're increasing the multiple, we can now increase by 2*prime instead of 1*prime,
so that we skip over even numbers, since we are now only considering odd k
- When we find a prime p, we add it to the prime and multiple list. However, we can instead add
its square to the multiple list, since for any number between p and p**2, if it's
divisible by p then it must be divisible by another prime k < p
(i.e. it will be caught by an earlier prime in the list)
"""
# Insert 2 into primes/multiples
primes = [2]
multiples = [4]
# Iterate over odd numbers starting at 3
for k in itertools.count(3, 2):
# If we've found enough primes, return!
if len(primes) >= n:
return primes
# For each prime found so far
for i in range(len(primes)):
# Increase its corresponding multiple in steps of 2*prime until it's >= k
while multiples[i] < k:
multiples[i] += 2 * primes[i]
# If its corresponding multiple == k then k is divisible by the prime
if multiples[i] == k:
break
else:
# If k wasn't divisible by any prime, add it to the primes/multiples list
primes.append(k)
multiples.append(k ** 2)
return primes
Some might find the docstring as well as comments too much - I find the comments help relate the code to the docstring. Open to suggestions!
I'd be willing to bet that the majority of results you find in that search will be men talking about how much women care about money... of course some women do, but far far from all of them
Beneath the large obvious green 'Subscribe' button there is some low-contrast grey text ('Continue reading') that, when clicked, hides the box. This is on Substack's side, not the author of the article.
I did this initially, but I believe it didn't work for all applications - some were still registering it as Caps Lock (e.g. VS Code IIRC).
Workman [0] was designed to be used on an ortho keyboard, though it is also usable on a normal keyboard. I suppose it's tricky to design for many modern features as they are not yet standardised between keyboards.
[0] https://workmanlayout.org/
I use Colemak-DH (modified version of Colemak that has less lateral hand motion - found I was getting slight wrist strain with normal Colemak). I find it more comfortable than Qwerty. I have not had any issue with keyboard shortcuts - Ctrl-Z/X/C are in exactly the same spot and Ctrl-V is shifted over by one key. Most shortcuts are placed to be memorable (e.g. Ctrl-F for Find), not to be ergonomic, so the keyboard layout doesn't really matter. The only place I've really had to customise is Vim, where I've remapped the motion keys back to where they are in Qwerty (actually shifted over by one to j/k/l/;).
On Gnome, switching keyboard layout is very quick and easy - there's an icon in the top bar by default - so I can use that when other people want to use my computer. When I use others' computers, I have to look at the keyboard but it is not too much hassle for me as I don't do this very often.
Ah I see. So non-kernel packages do not have access to native modules at all? I believe in Elm native modules were still possible, just not publishing them to the package database. But in this case I guess you wouldn't be able to put a native module in a GitHub repository and then pull this in as a dependency, which is equally rubbish.
Edit: EdwardDiego's answer clarified this for me
Correct me if I'm wrong, but that code seemingly only applies to kernel packages, i.e. packages which are made by the gren team [1]
Seems more like a check to make sure the version of the JS is compatible with the version of gren than anything else.
[1] https://github.com/gren-lang/compiler/blob/e665e521367eeedec...
Presumably it came from Latin 'puppis' (aft, stern, poop deck) before the passing through French to English.
The strong force is much stronger than the Coulomb (charge) force.
- Fuzzy file search - I can't find a way to do this in nano? Where you can search a whole directory by name for the file you want to open. This is very useful in larger projects when you need to jump about a lot.
- LSP and all its uses - jump to definition is a big one.
- Window management - while you can use a multiplexer, using one session allows copy/paste to work, saves your file/search/command history, etc.
- While often overstated, it is undeniably more efficient... once you've learnt it.
However, if you are not doing programming, but are just editing e.g. Linux config files, then I would probably stick to nano (in fact, I usually use nano for these jobs, since getting my neovim config to work when running as sudo failed).
I like this a lot. This is built upon Vosk [0], open source voice recognition. I must try it for some of my own projects!
[0] https://alphacephei.com/vosk/
It looks like they have a word (or multiple) for each letter of the alphabet. So CD is "change drum", git clone is " guest ice traps space cap look [Ctrl right - autocomplete]", where you can read the commands from the first letters of each word.
Edit: the default 'phrases' are here: https://git.sr.ht/~geb/numen/tree/master/item/phrases
Looks pretty. I can't scroll on the gallery page on mobile, and tapping anywhere on the page (including the top example) just brings up the navigation menu. Switching to desktop mode works.
I use Colemak DH, and have done for a few years. I could never touch type very well on QWERTY anyway so using QWERTY I am no slower than I was originally (in fact, I'm probably faster, since I now use my fingers properly). As long as it isn't very frequent, using hunt-and-peck on any QWERTY keyboards you come across is fine, and touch typing a different layout won't affect it.
Posted by
ArchieMaclean on Monday January 09, 2023 @07:10PM
from the show-hn dept.
https://pipescore.web.app/
I've been working on some version of this since May 2019. It is a web app that allows writing out music for the Highland bagpipe.While it uses the same notation as normal music, bagpipe music tends to have a greater focus on gracenotes (embellishments). Most music software does not deal with this very well (e.g. MuseScore just displays a list of every single possible embellishment, of which...
For the last point, you can wrap the object in parens:
let generatePerson =
name => ({ name, id: generateId() })
Posted by
ArchieMaclean on Saturday October 22, 2022 @10:13AM
from the show-hn dept.
/([^a-z]|^)rust([^a-z]|$)/i
Brendan Eich - wasn't banned per se, but resigned as CEO of Mozilla after it came to light he'd donated to a cause supporting the ban of same-sex marriage. This is all on Wikipedia.
Lichess has a 'fishnet' of donated servers [0] that allow you to analyse using Stockfish on proper hardware. You can have up to 20 deep analyses a day.
The web client uses Stockfish compiled to WASM which is decently fast.
If you're not an IM/GM, it's "good enough"
[0] https://github.com/niklasf/fishnet
I wouldn't really call Orcish / Dwarvish 'full languages' - they aren't developed that much. However, the two major Elvish languages (Quenya and Sindarin) are both a lot fuller.
Posted by
ArchieMaclean on Tuesday November 02, 2021 @06:04PM
from the pipescore.web.app dept.
Now that I think about it, I'm not sure I can come up with any non-contrived example (maybe this [1]). I guess what's good is that it fits right into the rest of Vim very nicely, so I can just edit like normal, instead of fiddling with regexes.
[1] https://youtube.com/watch?v=FXCitlsA7eQ