while (true) {

Status
You're currently viewing only herko's posts. Click here to go back to viewing the entire thread.

herko

Impoverished space lobster “doctor”
6,899
Moderator
[url=http://meincmagazine.com/civis/viewtopic.php?p=29625067#p29625067:2k6jxcew said:
Ardax[/url]":2k6jxcew]
Should I just consider the EmailAddress attribute as "irretrievably fucked" and accept whatever input I'm given?
Pretty much. I look for an '@' symbol in the middle of the string, but otherwise don't attempt to parse the damn thing. MTAs can do that, and unless I'm writing one of those, there's no need for me to attempt to validate the correctness of an email address.

I do this as well.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
[url=http://meincmagazine.com/civis/viewtopic.php?p=29696537#p29696537:2wz7yght said:
koala[/url]":2wz7yght]
[url=http://meincmagazine.com/civis/viewtopic.php?p=29694905#p29694905:2wz7yght said:
hanser[/url]":2wz7yght]Which of these do you prefer?

Code:
var delay = TimeSpan.FromSeconds(orderTicket.IsEmpty ? 10 : 2);

//Or:

var delay = orderTicket.IsEmpty ? TimeSpan.FromSeconds(10) : TimeSpan.FromSeconds(2);

First one. Second one is extra chars and harder to read.


I like the second one better, because it's easier to see that the value of delay hinges on whether the orderTicket is empty. Although it's true that it's longer and a bit more cumbersome.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
[url=http://meincmagazine.com/civis/viewtopic.php?p=29808729#p29808729:v96xs13v said:
Jonathon[/url]":v96xs13v]Why have a user management UI in your webapp when you can just bang SQL into the console? :judge: :facepalm:

Non-facetious answer: Job security for the programmer/DBAs? I've run into similar moves before. WE ARE THE KEEPER OF THE ACCESS; ALL ELSE SHALL BOW BEFORE US.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
[url=http://meincmagazine.com/civis/viewtopic.php?p=29898225#p29898225:1zmvnesc said:
Alamout[/url]":1zmvnesc]^ Hm, haven't encountered that one before. But I haven't had to do this stuff since...before that project started, it looks like. That's a little frightening... :eek:

Requests + BeautifulSoup make this fairly straightforward. Or, at least, as straightforward as it can be. If you are stuck using an actual browser because JavaScript, Selenium's WebDriver is probably your best bet.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
[url=http://meincmagazine.com/civis/viewtopic.php?p=31145695#p31145695:g8bk28kl said:
hanser[/url]":g8bk28kl]You know what's my favorite? When a library instantiates one of its dependencies directly, and uses its own instance (var foo = new Thing(this); foo.DoSomething()) as a constructor parameter for that object. And then repeats that pattern everywhere.

It makes refactoring super fun.

(If there's a name for this super awesome pattern, I'd like to know it.)

Lovecraftian initialization?
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
[url=http://meincmagazine.com/civis/viewtopic.php?p=32430559#p32430559:34fp1a2a said:
Drizzt321[/url]":34fp1a2a]
[url=http://meincmagazine.com/civis/viewtopic.php?p=32430459#p32430459:34fp1a2a said:
KallDrexx[/url]":34fp1a2a]O...M...G...

I'm stubborn as all hell and couldn't let my last 6 months of working on this project go to waste. After 2 weeks of going over packet captures byte by byte, trying to figure out wtf other projects work and mine doesn't work I came across an off the cuff comment that most likely explains why I can't get H264 video to stream properly.

What is it? Adobe's RTMP specification is extremely clear about the protocol's handshake. First byte is 3, next 4 bytes is a timestamp, next 4 bytes MUST be zeros, and the next 1528 bytes are random data that needs to be repeated by the peer for the connection to be successful.

So what does this have to do with anything? Let me quote from the first blog I found with an explanation:

Also, the RTMP specification 1.0 that is widely available online is "outdated". The reason it is "outdated" because this specification defined the handshake only for flv streaming.

:facepalm:

Turns out in order to do H.264 streaming you have to do some SHA 256 hashing of specific values (I guess?) in order to successfully do a handshake that allows playback clients to display H.264 video. The best part is that even though the specification is considered "outdated" there is no other specification, and half the questions related to this say to look at the source of an open source product that was pulled (because they took it commercial).

This is stupid as well because the video data that gets sent to the client already contains information explicitly stating "hey fyi I'm h.264 video" but for whatever reason Adobe hard coded their handshake format to require extra stuff.

So now I'm deep diving these other code bases trying to understand what they are doing so I can get this working.

I'm so pissed right now I can't even start to work on implementing this at the moment.

Dear lord that's a horrible spec. Why are you trying to do RTMP? Why not HLS?

I'm just about done converting our enterprise streaming video infrastructure from proprietary, five-figure products, with no mobile support, that fail and require hours a day of babysitting, to open source, HLS-only, based on nginx which works flawlessly so far and costs $0. I'm keeping the same encoders (VBrick) and player (JW).

Enterprise video is stupidly stupid.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
This data scientist uses Python extensively, and in production. The libraries are excellent, the tooling suits us, and as long as the calculations finish in a reasonable amount of wall time, we don't care that it could be faster if we only used a harder language to program in. Most computation-heavy libraries' inner loops are written in C if performance is a concern anyway.

Parallelizing Python isn't that difficult either, for our problems which are (thankfully) embarrassingly parallel. We just spawn more processes. Obviously this may not fit your problem space, but it works great for ours.

If you need more performance and you don't want to resort to full C, there's Cython, which can be quite performant. If you need/want a JIT, there's PyPy (admittedly not as stable as I'd like, so we don't use it yet). If you absolutely must have true multithreading, there's Jython.

It's not a perfect language by any means, and sure the default implementation could be better. The GIL is annoying as hell. But it's pretty damn great for expressing high-level algorithms and the kinds of computations my team cares about. It's also fantastic for writing quick one-off scripts for sysadmin tasks.

As far as I'm aware, even Google uses Python in production in public-facing systems. Sure, not performance-critical ones, but ones you may interact with regularly as a customer.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
To answer a question that came up before, no, our work doesn't qualify as "big data" in any meaningful sense of the word. I've done big data work (as in I've actually worked at Google on web-scale stuff, albeit 10 years ago). This isn't it. We're dealing with problems that fit in RAM on a workstation.

I wouldn't write extremely computation-heavy stuff for billions of rows with tight inner loops in Python. And yeah, my current problems don't have shared state. I'm lucky that way.

That was kind of my point, though: there's lots of problems that _can_ be tackled productively in Python. Is it a panacea? Not at all. Is it good enough for a lot of us? Hell yes.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
When your Ansible playbook has to deal with common failures deploying Ruby on Rails apps...
file.php
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
Yeah, no kidding.

I used to have a coworker who would ask me for help getting his code to work correctly. He'd do shit like take my (working, correct) answer and for no apparent reason replace all the semicolons with commas, or change the capitalization on random variable names (but only in their declaration, or only in half their references), and then complain that what I gave him didn't compile or didn't work. Yeah, no shit, Sherlock.

He got fired after about 6 months of several different senior devs having the same experience. To this day I cannot figure out if he was trying to get fired, or if he was really just that stupid (and if the latter, how the hell he got hired in the first place).

This is a dev embedded in a clinical department which has nothing to do with my organization. I think the "in the land of the blind, the one-eyed man is king" proverb applies; he's their technical wizard, but he's out of his depth anywhere else. I'm trying to pair him with one of my best devs to see if we can bring him a bit more up to par, because this isn't the first time this kind of thing happens, and it's always frustrating.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
Just got a 1-page of code via email. It's meant to talk to a web service. It's missing all context, data in the web service itself, comments, object ids, or anything else. It's in a language I don't usually work with (C#).

The request is "Can you please make this work?"


Yes:
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, world!");
            Console.ReadLine();
        }
    }
}

The code now works.

I wuv you so much.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator

herko

Impoverished space lobster “doctor”
6,899
Moderator
Seems to me that in scenario (3) you're not letting the optimizer do its job, by dictating an explicit execution plan ("select this first from here, then select foo from there, then bar from baz", etc.) This is generally a Bad Idea™ and should be avoided unless you have documented (usually performance-driven) reasons to do so.

Of the other two, I personally prefer Scenario (2) because I find it more readable, and it lets the optimizer figure out the join strategy.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
We have a #shame channel in our team slack for this purpose BUT... shaming other people is off-limits. It's only self-shaming. There's still plenty of contributions and learning opportunities, along with more than a few laughs. But no one is required to post or anything else.

I created the policy, and I contribute plenty :D

I think it also helps normalize making mistakes. Here's one of my recent favorites:
Code:
assert 0.0 >= quantity >= 1.0

Another one, titled "MOM WHY IS MY GRAPH EMPTY":
Code:
def make_graph(blah):
    G=nx.Graph()
    # do lots of stuff
    return G

if __name__ == "__main__":
   G=nx.Graph()
   make_graph(blah)
   print(G)

>>> Graph([])
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
I think it also helps normalize making mistakes.

It's not making mistakes that needs normalizing, it's discussing them.

Depends on your environment. There's some that pretend that "good" professionals never make mistakes. This is toxic and needs to get stamped out.

Normalizing discussing them IS good, of course.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
Python the language does not mandate specific implementations or specific performance for most built-in types, so they can't make performance claims in the language documentation.

CPython, the most common implementation (and to be less pedantic, what most people think of when they think of Python) uses a C array as backing.

The language/spec duality is why you don't see performance characteristics described in the main documentation, AFAIK. There's also PyPy, IronPython, Jython, GraalPython...
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
I'm an electrical/controls engineer, and my day-to-day programming is generally in Ladder Logic. Lately, I've been able to work a bit with Python, thanks to Ignition.

So now, I want to get back into hobby programming - in college, I primarily used C/C++ and Python - but I'm out of practice and I'm not afraid to learn a new language.

Some ideas I want to pursue:
  • Recipe keeper and grocery list generator - Would be nice to make a better setup and interface than my current Excel document. I eventually want to make this phone-friendly, but I want to get the idea working first.
  • Home Automation - I have an RPi and some Z-Wave devices, but I'll need to finally get Internet to my house for this to be worthwhile.
  • Simple games - Not sure how well this would go, I'd be worried about sinking time into graphics.
  • Robotics

I first thought I'd just use Python, but since I haven't researched programming languages in years, I want to ask the hive mind... What would y'all recommend?

Still Python, honestly. It's insanely powerful at this point, and there's libraries for everything.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
A negatively named method (like boolean isNotAbleToDoSomething()) with 4 negations (!s) inside, that is then called in a boolean expression as !obj.isNotAbleToDoSomething().

:facepalm:

I literally can't follow the logic.
I'm a new starter on a codebase that is fairly full of that sort of thing, but with the added spice of nullable bools with crazy defaulting logic and also where all of the variables are named value/obj/parameter etc

Every time I refactor these methods into something sensible my pairing partner tells me to undo the changes before we commit because 'its not part of our change and we need to keep the PR small to get through change management'. Is two weeks established enough to start swearing?

In your case, it's not just enough; you've waited too long.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
That’s normal in places with metastatic infosec.
Our infosec is metastasizing, but not completely there yet: my department managed to carve out a little corner for itself, ONE server hosting ephemeral VMs to do temporary/demo stuff.

We also, thank the FSM, have root on our machines (including prod) so we can fix stuff when it breaks and file a change notice after the fact. This is still allowed, and in fact leveraged - all print spoolers on Windows servers were immediately disabled when the latest vulnerability was discovered, for example.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
I probably repeat myself, but I wish someone tries to compile userland terminal bits of a mainstream Linux distro to run in a WASM environment with few dependencies. WASM is friendly to sandboxes, so I think you could create an entire environment that can run under a regular user on Windows, Mac, *and* Linux, is super portable, and probably would have decent performance.

This is basically what you mention
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
Relying on no specifics, only stereotypes, what programming tasks would a "20-something, young, talented and hip programmer" be expected to do better than "20yr veteran programmer" assuming both are skilled and talented to at least the 80th percentile of their peers.

One obvious one is that the former is far more likely to agree to working insane hours and low pay for either idealism (Open source or charity) or capitalism (stock-options or percentage ownership of the company)

If cost/salary are not a factor, when would hiring young and talented guy be the smart move?

When you need some freshness? If you hire a recent grad, they'll be more up to date on whatever academia thinks are best practices.

Also, for business continuity. If all your employees are older, who's going to take over when they retire?
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
I'm really starting to believe that Exceptions are just the literal devil and even worse than GOTO for everything other than log-and-bail-out.

Exceptions + Polymorphism = you have no idea how you actually got to the current line, but you have the mistaken belief that you have some clue as to how you did.

Checked Exceptions could help if people didn't just squash them, but they do, so they don't.

Exceptions should be exceptional. It's log and bail out, yes. Anything else that requires you to do some control flow, you should do with other means.

It's fun how the Python docs ( https://docs.python.org/3/glossary.html#term-EAFP ) say they favor exception for control flow ("Easier to ask for forgiveness than permission", EAFP) over look before you leap (LBYL), but Guido himself has hinted he favors LBYL ( https://mail.python.org/pipermail/pytho ... 33118.html ).

...

With that consideration in mind, I think only Rust does something interesting wrt. to error handling. Return-code based error-handling without enough ergonomics (C, Go) is excessively inconvenient and error prone.

We do a lot of Python at work and -with some limited carveouts- LBYL seems like the only sane way for large-ish or bigger projects. Sure, if you're writing a 100-line shell script, you can EAFFTP.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
Mainly error reduction and automation. I posted it here, but I had to determine underpayments due to a contract change that no one else wanted to do. I could have done it manually in Excel using some pivot table work (I guess?) but I used Pandas and Python to match up, do the math, and drop it into another dataframe with the new amounts. Once I had the script down, it worked like a charm.
I think the accomplishment here is double-checking the math, and acting on it.

Recognizing that there might be a problem, bringing domain knowledge to bear, and implementing the solution. The Python part is incidental; as you say, it can be done in Excel. WHICH tool isn't as important as "I can bring tools to bear, and know how to apply them."

If you're trying to get the keywords to pass an automated scan, that's valid, but otherwise I'd focus more on the accomplishment TBQH.
 
  • Like
Reactions: zeotherm

herko

Impoverished space lobster “doctor”
6,899
Moderator
You’re serving petabytes of Isilon through SMB? how’s that going for you? We found windows locking to specific front end nodes at a client node (box) level a nightmare as one overloaded front end node eventually hoovered up all the users by not failing but going really slowly.

NFS (both versions) has all sorts of other problems of course.
We do this (serve PB to thousands of people through SMB from Isilon). It mostly works, although permissions on folders twist themselves into a pretzel about once a year. And I have no idea if that is related to using SMB; I'm merely a consumer.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
Playwright is SO good I want to write more scrapers now (to fix personal itches with unusable websites).

I knocked out a scraper for a manual task that was bothering so much... that I don't think I'd been able to do with Selenium. Perhaps there are more powerful scrapers these days, but Playwright rocks.
I'm teaching my employees to use Playwright right now to liberate internal data from bad webapps. I used to use Selenium for this, and it generally works, and is insanely powerful... but it is a LOT to navigate.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
macOS handles memory very differently on Intel vs. AS in my experience. RAM isn't as clutch as it used to be in the Apple Silicon world since the memory manager seems to handle it differently. I don't think for an AS machine you need to max it out as much as was necessary in the Intel world.

Given your post and my usual advice to buy as much as you can afford (with the caveat that 128 GB of RAM is bonkers but awesome and almost certainly completely unnecessary), I'd probably recommend the 16/40 with 64 GB*. It's extraordinarily future proofed and well suited to (what I perceive are) your needs.

That said, if you'd rather prioritize lightness/portability over power (or price), the Air will still be one heck of a machine.

* I had a 64 GB M1 for my last job. As a Java dev who runs IntelliJ IDEs I'm a bit of a RAM user, and I found the memory usage almost never got above 32 GB even when I was running multiple servers and IDE instances. I could force it way high by giving IDEA some crazy memory settings, but Apple seems to have really upped their memory management game in AS Macs. I'm fairly confident that 64 GB will suffice for the useful life of the machine unless you're already working with extraordinarily large memory requirements.
I have a 64 Gb M1 Max Mac Studio and a 32 GB M1 Max MBP and I endorse this post. I usually run several VMs simultaneously plus a full complement of other tools, including JetBrains IDEs. 32 GB is enough, 64 is not going to be short for anything other than very, very large datasets.
 

herko

Impoverished space lobster “doctor”
6,899
Moderator
Thanks all. Very helpful.

Any of you running local LLMs?
Yeah, I run Llama models on my 64 GB Mac Studio to play with them, using llama.cpp. Quantized 70B parameter models are no problem; they take about 36 GB of RAM. Performance is... acceptable (it's 'only' an M1 Max). Enough to play with, not enough that I'd like to use it production anywhere.
 
Status
You're currently viewing only herko's posts. Click here to go back to viewing the entire thread.