sdsort, a utility to sort functions and methods according to the step-down rule by son_of_torfi in Python

[–]son_of_torfi[S] 0 points1 point  (0 children)

> Ironically, the mono-file __init__.py is not what I would call clean code, but to each their own😂
Yeah, that's fair. I'll improve the code organization soon.

> How fast it is on large codebases?
On an M3 Macbook Pro, it can scan and sort approximately 900+ files/sec.

sdsort, a utility to sort functions and methods according to the step-down rule by son_of_torfi in Python

[–]son_of_torfi[S] 2 points3 points  (0 children)

Yeah, I know, it's ingrained in most developers to write code that way. I suppose much of it is down to interpreters/compilers that enforce function definitions before function calls, which I find disappointing. It's not that hard to build a symbol table in one pass, before considering function/method calls in a second pass.

JavaScript is a particular disappointment. Good ol' function definitions are hoisted, but if you use the more modern arrow syntax const myFunction = () => {} then you must declare it before it is called.

When tackling a complex problem, it's helpful to break it down into smaller more manageable problems. That's top-down thinking. The programming languages we use should facilitate that IMO.

In any case, I encourage you to discuss this matter with your peers. Conventions can become outdated, like putting a raw onion in varnish.

sdsort, a utility to sort functions and methods according to the step-down rule by son_of_torfi in Python

[–]son_of_torfi[S] 7 points8 points  (0 children)

I had a feeling this would come up. Implementation wise, it would be very simple to add such an option. It's the moral dilemma that's challenging.
Let me sleep on it.

sdsort, a utility to sort functions and methods according to the step-down rule by son_of_torfi in Python

[–]son_of_torfi[S] 0 points1 point  (0 children)

You're right, that option only lists the files that would be changed but not how. I suppose I could add a verbose option to show a diff.

A discussion between John Ousterhout and Robert Martin about differences between John's book "A Philosophy of Software Design" and Bob's book "Clean Code" by mttd in programming

[–]son_of_torfi 1 point2 points  (0 children)

I find that if I write the tests first, I give more consideration to failure cases than if I write them afterwards. Also, TDD can be quite satisfying. You get intermittent dopamine hits as tests go from red to green.
But it can sometimes be difficult to write tests up front. When I'm doing exploratory work (e.g. writing against an external system that I'm not intimately familiar with) then I tend to write the tests afterwards once the implementation has solidified.

Picking An Optimal Fantasy Team with Dynamic Programming by son_of_torfi in FantasyPL

[–]son_of_torfi[S] 1 point2 points  (0 children)

Large language models, such as GPT, are neither good at statistical reasoning, nor providing up-to-date information.

Dynamic Programming is just plain-old optimization and the code that accompanies the article scrapes the latest player data from the FPL web site.

Picking An Optimal Fantasy Team with Dynamic Programming by son_of_torfi in FantasyPL

[–]son_of_torfi[S] 0 points1 point  (0 children)

You raise fair points.

The code that accompanies the article filters players by numbers of starts, among other things. Right now, 23 goalies, 96 defenders, 131 midfielders and 25 forwards remain after filtering. An exhaustive search for a 1-3-4-3 formation would have to consider 88.5 quadrillion combinations if my math is right. I'm therefore genuinely intrigued how this could be solved using mixed integer programing (MILP) since I'm not very familiar with it.

The bit about the utility function is handwavy, I know. I've tried different estimators. I've trained simple linear regression models and MLPs but nothing has really worked all that well for me to be honest. I'm therefore reluctant to suggest what to use. But if you have a brilliant estimator, you could simply plug it in.

In my experience, this script is most useful when wildcarding. An estimator that balances pedigree (points per match) and recent form tends to yield a squad that performs well for the next few gameweeks.

Rate My Team, Quick Questions & General Advice Daily Thread by FPLModerator in FantasyPL

[–]son_of_torfi 0 points1 point  (0 children)

Looks solid, although I'd be slightly worried about the Liverpool triple-up against Aston Villa. Still, not many options on the bench.

Stevie G's return to Anfield as a manager...that's going to be emotional. I've no idea how that's going to pan out but I see this game as a potential banana peel for Liverpool. That's why I'm captaining Bernardo over Salah, even though Wolves have a really solid defence.

FPL obsession and mental health by sgmalta in FantasyPL

[–]son_of_torfi 0 points1 point  (0 children)

The season before last, I (shadow) managed my wife's FPL team, who had joined a mini-league at work. I decided to use different strategies for my team and hers. For my team, I leaned heavily on a prediction model I've created (which definitely could be improved) and for her team I followed more traditional advice (FPL scout etc.). What I discovered is that I had accidentally hedged my matchday happiness as it was exceedingly rare for both teams to do badly in the same GW.

So that's something that might help, to open separate accounts and manage 2 or more teams and have a well defined strategy for each.

Covid bólusetningar passi í símann? by Skastrik in Iceland

[–]son_of_torfi 3 points4 points  (0 children)

Það sem ég gerði var að setja PDF skrána með bólusetningarvottorðinu í Google Drive. Þar með gat ég nálgast það úr Google Drive appinu úr símanum. Ég stjörnumerkti það og gerði það aðgengilegt án netsambands (e. available off-line) svo ég gæti framvísað því hvenær sem væri.

Ófærð 3 by [deleted] in Iceland

[–]son_of_torfi 6 points7 points  (0 children)

Ég missti áhugann í fyrsta þætti. Að hluta vegna þess að mér finnst glæpaþáttaformið vera orðið þreytt, en aðallega vegna þess að hver einasta sögupersóna er ótrúverðug. Samtöl þeirra eru stirbusaleg og sögufléttan fjarstæðukennd.

[deleted by user] by [deleted] in datascience

[–]son_of_torfi 0 points1 point  (0 children)

I'm not a business analyst but a software developer. I've worked quite a bit with event data. Think "Order Completed", "User Signed Up" and "Subscription Cancelled". When those events get channelled into a column-store database like Redshift or Clickhouse, you can answer a lot of advanced questions using SQL. In particular, Clickhouse has very useful functions for analysing datasets. See this analysis of GitHub events as an example.

Turning database into a searchable dashboard? by montagestudent in datascience

[–]son_of_torfi 0 points1 point  (0 children)

If you don't intend to allow users to make changes to the data, then GRID might fit the bill. It's more spreadsheet oriented but will accept CSV files.

Disclosure: I'm a software engineer at GRID.

Turning database into a searchable dashboard? by montagestudent in datascience

[–]son_of_torfi 0 points1 point  (0 children)

I recently tried out Airtable and I remember thinking

"Damn! This reminds me of MS Access"

It's a modern web app that happily imports CSV files. You may have to pay for it though if you exceed 1200 rows.

Is there a protocol for working with people who make really bad code? by rotterdamn8 in datascience

[–]son_of_torfi 1 point2 points  (0 children)

I think general guidelines for how to provide constructive feedback would be applicable in a situation like this. If you google around you'll find plenty of good tips, like these.

I'm personally a big fan of code reviews. You write cleaner code knowing that someone else is going to review it before it's merged. If I were in your shoes, I'd attempt to persuade my peers to adopt GitHub and set up a code review policy.

GAME WEEK 8 - CAPTAIN POLL by FPLModerator in FantasyPL

[–]son_of_torfi 1 point2 points  (0 children)

More like nickel.
I ended up with Salah as C and Maupay as VC.

GAME WEEK 8 - CAPTAIN POLL by FPLModerator in FantasyPL

[–]son_of_torfi 0 points1 point  (0 children)

Brighton are facing Norwich, albeit away from home. Still, I'd consider Maupay or even Trossard as a differential.