whitequark,
@whitequark@mastodon.social avatar

found some extremely Normal code in one of my projects

whitequark,
@whitequark@mastodon.social avatar

do you think there's something wrong with me?

mcc,
@mcc@mastodon.social avatar

@whitequark I have written Lua professionally so

whitequark,
@whitequark@mastodon.social avatar

i also write python like this sometimes

val,
@val@oc.todon.fr avatar

@whitequark why not read the file from JS and pass its content to pyodide.runPython?

whitequark,
@whitequark@mastodon.social avatar

@val the file is in the python emscripten filesystem

whitequark,
@whitequark@mastodon.social avatar

@val oh i just realized you're right, pyodide.FS would let me do that

val,
@val@oc.todon.fr avatar

@whitequark I didn't realize it was its own filesystem, but glad I could help :D

whitequark,
@whitequark@mastodon.social avatar

@val i rewrote it to use pyodide.FS and the error handling gets really gnarly so I'll keep it this way

sanfierro,

@whitequark Well, honestly, I think it raises the entry threshold for reading this code. Now if you have all the knowledge necessary to read it, is it actually easier to read it if it's written like this? I imagine no, but I'm not an expert, so idk. I think it may be good in context where it's not expected to change at all however far into the future and it's just easier for you to write like this or you want to show off (nothing wrong with it in and of itself!)

whitequark,
@whitequark@mastodon.social avatar

@sanfierro so the reason it's written like this is because I don't want to pollute the global namespace with f which would happen if I ran e.g. with open() as f: normally

same with the import

it, regretfully, serves a purpose

sanfierro,

@whitequark Oh, I see, can't estimate if that purpose makes sense, I assume it very much does, because seems like you know what you do

whitequark,
@whitequark@mastodon.social avatar

@sanfierro basically i want to not affect the global environment at all, like if the code was never there

python has some really weird choices about the global scope and i have to use an equally weird workaround for it

sanfierro,

@whitequark Oooh, I see, interesting! Does it work in interpreters other than CPython?

whitequark,
@whitequark@mastodon.social avatar

@sanfierro yeah this works in any python implementation

whitequark,
@whitequark@mastodon.social avatar

someone suggested i use a library instead of importModuleCriminally and the library is like this

(I think it's slightly better than what I wrote?)

azonenberg,
@azonenberg@ioc.exchange avatar

@whitequark I mean I'm bridging AHB to APB over quad SPI. This is far from the most cursed thing I've seen in the past 24 hours.

mntmn,
@mntmn@mastodon.social avatar

@whitequark no, it is normal computering

dave_andersen,
@dave_andersen@hachyderm.io avatar

@whitequark but it does seem like there's something wrong with vs code.

whitequark,
@whitequark@mastodon.social avatar

@dave_andersen they shipped newer node i think, i'm gonna look at updating it

sanfierro,

@whitequark there's something awesome, creative, cute, smart, generous, helping, caring, nice and overall good with you

whitequark,
@whitequark@mastodon.social avatar

@sanfierro blush

djsundog,
@djsundog@toot-lab.reclaim.technology avatar

@whitequark jesus

whitequark,
@whitequark@mastodon.social avatar

@djsundog i was very tired and annoyed

it works*

  • in the narrow domain it is being applied to
easrng,
@easrng@crimew.gay avatar

@whitequark next time use https://www.npmjs.com/package/js-tokens :3 (or for this specifically, shimport)

whitequark,
@whitequark@mastodon.social avatar

@easrng ooooh, shimport is super nice, thank you! I think I can just remove the code though since VS Code has updated their Node

whitequark,
@whitequark@mastodon.social avatar
qlp,
@qlp@linh.social avatar

@whitequark importModuleCriminally 🙃

buherator,
@buherator@infosec.place avatar

@whitequark that "almost all" looks like a fun challenge for future you :)

whitequark,
@whitequark@mastodon.social avatar

@buherator I'm actually looking at it right now and vscode has updated node from 18.15 to... drumroll... 18.18. one short!

whitequark,
@whitequark@mastodon.social avatar

@buherator okay, vscode 1.90 will bring electron 29, which will bring node 20, which will solve my problems

whitequark,
@whitequark@mastodon.social avatar

@buherator probably. hopefully

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines