The Joys Of Programming

Built something ridiculously stupid and yet, am very proud of it. I’ve spent way more time on the backend than I expected (implementing proper weighting, unfurl support, etc), but that’s what happens when goofball ideas take you. Feel free to look upon my Ruby code without any tests and gasp in horror.

You built something brand-new? In this grandiose parfait law firm??

double post

*Legion* wrote:

A guess pulled out of my ass: I'm guessing the presence of either the setTimeout or the lambda function within prevents some optimization or JIT compilation or something of the entire B() function that the A() function enjoys due to the absence of them.

This was my first thought too.

I retyped it on jsbench.me and tried a few variations and the arrow function vs a named function doesn't really factor in, nor the setTimeout specifically.

Setting up with an external named function exhibits the same behavior:

function C() { console.log(count); }
function B() {
...
if (false) C.call(this);
...
}

The issue is the reference to 'count' in the function:

function B() {
...
if (false) setTimeout(() => {
console.log(count); // <-- Change this to not reference 'count' and all is fast.
}, 100);
...
}

It's the binding of 'this' in the nested function scope. If you take out the console.log(count) in the C function, or the arrow func, then it performs the same.

Regardless of it actually being called, the nested function is still getting it's own scope with 'count' in it.

merphle wrote:

You built something brand-new? In this grandiose parfait law firm??

IMAGE(https://media4.giphy.com/media/AKaEfzaLlr0yI/giphy.gif?cid=5e2148863ctdxdk5ybg9i404gohgyclfgjgxdvsaealm0wqs&rid=giphy.gif)

trueheart78 wrote:

Built something ridiculously stupid and yet, am very proud of it. I’ve spent way more time on the backend than I expected (implementing proper weighting, unfurl support, etc), but that’s what happens when goofball ideas take you. Feel free to look upon my Ruby code without any tests and gasp in horror.

Grotesque Paperclip Factory was the name of my industrial cover band in high school.

What started off as a goof at work from a misspelling of bin/run as bun/run once has snowballed into a silly little script that makes me smile.

Carrot Chase

And yes, now if I type bun [command] it executes that script and then runs bin/run for me.

This one made me laugh.

IMAGE(https://i.imgur.com/Dvks2Ma.jpg)

IMAGE(https://i.imgur.com/92SGBHj.png)

Blaseball came back and I had to make a few minor changes to get my fan site working again at the beginning of the week. And then sometime on Wednesday they added four teams in the middle of the season that had 0-0 records, but didn't play any games. Completely broke a ton of code that had a hard coded team count that I had to make more flexible. Fun, but annoying. I am hoping to add something to display the playoff bracket and update it live during postseason.

Malor wrote:

IMAGE(https://i.imgur.com/92SGBHj.png)

I used a variant of that joke (dev choosing to solve a problem using regex) this past week. The developer who had used regex was not as amused as I felt he should have been.

billt721 wrote:

I used a variant of that joke (dev choosing to solve a problem using regex) this past week. The developer who had used regex was not as amused as I felt he should have been.

"A lot of people have tried to solve that problem using regexes":

IMAGE(https://i.imgflip.com/3gwdow.png)

*Legion* wrote:
billt721 wrote:

I used a variant of that joke (dev choosing to solve a problem using regex) this past week. The developer who had used regex was not as amused as I felt he should have been.

"A lot of people have tried to solve that problem using regexes":

IMAGE(https://i.imgflip.com/3gwdow.png)

They tried and failed?

They tried AND DIED!

My version of this truth is

"Sometimes you have a performance problem ... so you add a cache ... and now you have a performance problem *and* a correctness problem"

psu_13 wrote:

My version of this truth is

"Sometimes you have a performance problem ... so you add a cache ... and now you have a performance problem *and* a correctness problem"

This is my pain

Have spent multiple late nights working on a custom personal project that is coming along swimmingly. When I say “late nights”, I mean 5am, 6am, and 8:45am, respectively.

From the Win of the Day thread:

trueheart78 wrote:

I have an app on my iPhone/iPad called Working Copy and it makes it too easy to unload my brain when it won’t stop. Clones repos, commits, pushes, etc. Add in the site Repl.it, and I can even test out my code questions/concerns from my tablet...

I definitely program slower, but from the couch I can prove out ideas. Heroku has a “deploy all pushes to main branch” option and that makes is super easy to keep this Food Tracker up-to-date since it’s storing data in YAML files, kept in the repo. The iPhone version makes it so easy to keep my data up-to-date, too. IMAGE(https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/softbank/145/sparkling-heart_1f496.png)

Re: storing the data in static files

Yes, I could use a database, but since these are read-only interactions, and updating the data from my non-laptop devices would be more painful if I were using a proper database, this is working out surprisingly well. I’m also using Sinatra instead of Rails, so it’s already quite lightweight. Even with data files being loaded and lines being parsed (and not cached), it loads quite fast. I haven’t timed it, but until we get into the 1sec+ page load times, I’m not even gonna bother with attempting to cache things.

The above comment already makes me hesitant to even consider caching. I mean, it’d just be an added resource (Redis) and require extra cpu cycles to detect if it’s out-of-date... *shakes themselves out of it*

psu_13 wrote:

"Sometimes you have a performance problem ... so you add a cache ... and now you have a performance problem *and* a correctness problem"

I love Working Copy and recently played with it in conjunction with Pythonista, Scriptable, and Shortcuts (all on iOS). It’s pretty remarkable what we can do on these things, and I’m not particularly bright or good at programming.

One of the reasons I like Dart so much is that the syntax is so clean that I have been able to make a lot of fixes straight from the git web site and they work the first time.

My next small feature update is to use this tutorial to update the url on view changes and make a copy and pastable site-specific link, like "hey, check out the wild league party time numbers (link)"

https://medium.com/@nagachaitanyakon...

IMAGE(https://i.redd.it/5jryn7vtjqo61.jpg)

Malor wrote:

guthib.com

Shame they don't tell you that, make you stew for a few seconds, and then redirect you on. I've bought at least one domain to redirect to a site I could never spell correctly.

Mixolyde wrote:

One of the reasons I like Dart so much is that the syntax is so clean that I have been able to make a lot of fixes straight from the git web site and they work the first time.

I appreciate that when Mix makes a post in this thread, there's at least a 60% chance that it references Dart.

*Legion* wrote:
Mixolyde wrote:

One of the reasons I like Dart so much is that the syntax is so clean that I have been able to make a lot of fixes straight from the git web site and they work the first time.

I appreciate that when Mix makes a post in this thread, there's at least a 60% chance that it references Dart.

Hold on, I wrote a script to calculate that percentage...

Mixolyde wrote:
*Legion* wrote:
Mixolyde wrote:

One of the reasons I like Dart so much is that the syntax is so clean that I have been able to make a lot of fixes straight from the git web site and they work the first time.

I appreciate that when Mix makes a post in this thread, there's at least a 60% chance that it references Dart.

Hold on, I wrote a script to calculate that percentage...

in?

kazar wrote:
Mixolyde wrote:
*Legion* wrote:
Mixolyde wrote:

One of the reasons I like Dart so much is that the syntax is so clean that I have been able to make a lot of fixes straight from the git web site and they work the first time.

I appreciate that when Mix makes a post in this thread, there's at least a 60% chance that it references Dart.

Hold on, I wrote a script to calculate that percentage...

in?

Textpad.

Question for yall, and then an answer to a common project question. My 10 year old has expressed some interest in learning to code, though it was presented as the lesser of all evils. More book reports, foreign language study, and learning a musical instrument were all rejected, but I can always circle back. So far, I've had some success with having him work through https://code.org/hourofcode/overview , but they're all pretty basic. We've started assembling nintendo labo projects, but they don't feel particularly STEM-like and I'll probably run out quickly. What should I do next? I know if I just throw an intro python course at him, he'll lose interest in the abstract problems that intro courses tend to teach. I am a software developer by trade, but I need a curriculum that is at least partially self-study so it's more than just nonstop tutoring.

I just looked at the first post in this thread and https://inventwithscratch.com/ looks like it might be along the lines of what I want, but might be too freeform. If I don't find anything more guided, I'll probably give it a shot anyway. I'm concerned that the problems being solved in http://inventwithpython.com/ simply won't interest him.

detroit20 wrote:

What I'm currently struggling with is my next step. I think that I'll be best served by ... a few hobby projects of my own to practice with. My first little project is to pull some NFL-related html data off a website, clean it, then store it in a database then visualize it.

Does anyone have any advice on a follow-up course? And what other small projects might I consider at this novice stage?

What data are you scraping? Also, have you seen the nflfastR dataset?

Hobby projects have always been a challenge for me to find, as I'm not interested in writing code for the sole purpose of professional development.

I taught myself python (not my first language) partially by learning to scrape fantasy football projections and produce optimal fanduel lineups, which I would then add to as many $1 50/50s as I could find. It actually turns out to be an instance of the knapsack problem. Having a little skin in the game kept me motivated enough to keep doing it for 2 seasons, but I don't need to teach my child to gamble. The code is terrible and should not be used to learn from, and was last used to scrape fantasypros in 2015, so should be quite broken by now.

If you're more interested in automating your life and less in traditional software development, there are a couple of other routes you can take with small projects:

Zapier. I've tasked my child with writing one book report a week, but it was a lot more during the summer. We maintain a list of books in a google sheet, I update the ones that are checked out from lapl.overdrive.com by hand, use formRanger to populate a google form, and zapier to both create a google doc from the form submission and notify me on my family slack. I then remove the book from the list.

Autohotkey. I wrote a bot for Marvel Future Fight a few years back in autohotkey, to do all of the daily grinding. Run an android emulator, try to detect whether icons are enabled or disabled, navigate menus, etc. A much more simple script can enter in a key sequence down to the millisecond if you need to perform a particular combo in a game.

Selenium. This is a web automation/QA testing tool that's been around forever, and possibly the closest of the three to a marketable professional skill. I used to play a browser game about 15 years ago and automated that in (I think) selenium. I would trigger it via cron every 4 hours. Originally all I did was collect resources, but eventually added the most boring minigames one at a time, and combat for xp. Selenium is old and creaky, so you might be able to find a more appropriate tool depending on the language you prefer. The last time this came up at work, we were using typescript, so nightwatchjs came up.

Emmes wrote:

Question for yall, and then an answer to a common project question. My 10 year old has expressed some interest in learning to code, though it was presented as the lesser of all evils. More book reports, foreign language study, and learning a musical instrument were all rejected, but I can always circle back. So far, I've had some success with having him work through https://code.org/hourofcode/overview , but they're all pretty basic. We've started assembling nintendo labo projects, but they don't feel particularly STEM-like and I'll probably run out quickly. What should I do next? I know if I just throw an intro python course at him, he'll lose interest in the abstract problems that intro courses tend to teach. I am a software developer by trade, but I need a curriculum that is at least partially self-study so it's more than just nonstop tutoring.

I just looked at the first post in this thread and https://inventwithscratch.com/ looks like it might be along the lines of what I want, but might be too freeform. If I don't find anything more guided, I'll probably give it a shot anyway. I'm concerned that the problems being solved in http://inventwithpython.com/ simply won't interest him.

Some options. Amazon has many to choose from. Be wary, the Python book is from 2012, and the Ruby one from 2014.

- Python for Kids: A Playful Introduction to Programming

- Ruby Wizardry: An Introduction to Programming for Kids

- JavaScript for Kids: A Playful Introduction to Programming

If you need more books to never read, HUMBLE BOOK BUNDLE: LEARN YOU MORE CODE BY NO STARCH PRESS is going on right now.

trueheart78 wrote:
Emmes wrote:

My 10 year old has expressed some interest in learning to code

Some options. Amazon has many to choose from. Be wary, the Python book is from 2012, and the Ruby one from 2014.

- Python for Kids: A Playful Introduction to Programming]

Much appreciated!

As you strike out on your programming adventure, you’ll learn how to:
–Use fundamental data structures like lists, tuples, and maps
–Organize and reuse your code with functions and modules
–Use control structures like loops and conditional statements

I'm not sure how to say this, except that I can picture very clearly in my head my child protesting how the difference between a list and a tuple just sounds like work and therefore the literal definition of boring. I can make it happen, but I'm concerned that I will ruin his interest in the topic forever if I push too hard for the sake of results. Any advice on this would be appreciated. I've talked with him about maybe working directly in unity or something and trying to make a game, which could be a natural source of projects to make.

PS - Yes, they're spoiled. Still, I only get one chance at maintaining interest in this particular topic.

My kids went through Code.org Course 1 in middle school (age 13ish). It's all block-based coding, with a specific goal for each lesson, and they're generally cute & fun. The first couple of "lessons" are just learning the basic concepts of how to drag things around to form code blocks, so depending on how advanced he already is, you might be able to start him up around lesson 4 "Maze: Sequence".

This course teaches things like sequential processing, conditional if/then, looping. Fundamentals of programming that are useful in most other modern languages.