613 karma · joined Jun 5, 2019 (7y ago) · 165 submissions
comment 5mo ago · link · parent
Maybe I missed the point, but the aside about parking metres seems irrelevant. Just makes me think this is an anti-technology rant.
And again, the gripe about splitting up the bill. Not only is that a problem with existing systems, it's a problem that is solved by QR codes (if implemented correctly).
comment 5mo ago · link · parent
It doesn't miss it. The whole framing of the article is the Dooman Fallacy - an organisation trying to save money by shifting [apparently] menial work to the customer ends up losing more than they save.
comment 1y ago · link · parent
Having worked at AI (a long time ago), I can assure you this isn't some mastermind plot to sneak a couple of cookies onto the computers of the one or two people who click through to settings.
comment 1y ago · link · parent
Put another way, I strongly disagree that the clipboard is the main obstacle. (And fwiw, Linux has been my main OS for decades)
comment 1y ago · link · parent
MacOS neatly avoids this issue with the command key, but I'm not sure what happens in Windows.
comment 2y ago · link · parent
The article seems to imply that kindness/correctness are somehow mutually exclusive. Even if that wasn't the author's intent or belief, it certainly seems to be the way some commenters conduct themselves.
comment 2y ago · link · parent
Pathname.glob('*').filter { |f| f.file? }.each_with_object({}) { |f, h| h[f.size] = f }
Whereas the equivalent Python would be: result = {}
for file_path in glob.glob('*'):
if os.path.isfile(file_path):
result[os.path.getsize(file_path)] = file_path
Or capitalizing a string in Ruby: string.split(' ').map(&:capitalize).join(' ')
And in Python: words = string.split(' ')
capitalized_words = [word.capitalize() for word in words]
result = ' '.join(capitalized_words)
Python seems to be more convoluted and verbose to me, and requires more explicit variable declarations too. With the Ruby you can literally read left to right and know what it does, but with the Python, I find I have to jump about a bit to grok what's going on. But maybe that's just my lack of Python experience showing.comment 2y ago · link · parent
a) put a `binding.irb` (or `binding.pry`) in any rescue block you may have in your script - it'll allow you to jump in and see what went wrong in an interactive way. (You'll need a `require 'irb'` in your script too, ofc)
b) I always use `Pathname` instead of `File` - it's part of the standard library, is a drop in replacement for `File` (and `Dir`) and generally has a much more natural API.
c) Often backticks are all you need, but when you need something a little stronger (e.g. when handling filenames with spaces in them, or potentially hostile user input, etc), Ruby has a plethora of tools in its stdlib to handle any scenario. First step would be `system` which escapes inputs for you (but doesn't return stdout).
d) Threads in Ruby are super easy, but using `Parallel` (not part of the stdlib) can make it even easier! A contrived example: `Parallel.map(url_list) { |url| Benchmark.measure { system('wget', url) }.real }.sum` to download a bunch of files in parallel and get the total time.
MacOS has Ruby 2.6 installed by default which is perfectly serviceable, but it's EOL and there are plenty of features in 3+ that make the jump more than worthwhile.