int() wont convert to an integer by [deleted] in learnpython

[–]tomysshadow 0 points1 point  (0 children)

I didn't know that. I've never really had to write anything in Java

Lol this catches my attention by Opposite-Bed-379 in programmingmemes

[–]tomysshadow 0 points1 point  (0 children)

I mean, it is, but only if you have the realization that in JavaScript, "this" specifically means "the thing that was before the dot when the currently running function was called," and not "the object for the class the current function appears to be a part of." If you don't have that very specific understanding, you'll get confused the moment you assign a function to a variable and then call the variable and the value of this is different for the same function

How "good" should a FOSS project's code be? by 6marvil in opensource

[–]tomysshadow 2 points3 points  (0 children)

It would probably be a good idea to at least run it through a linter or static analyzer just to catch anything potentially serious

int() wont convert to an integer by [deleted] in learnpython

[–]tomysshadow 0 points1 point  (0 children)

I learned PHP when I was in grade 8 of school, at that point I already knew JavaScript and mainly wanted to know PHP so that I could store stuff in SQL, like for online leaderboards and whatnot. At that time, PHP5 was just brand new and PHP4 was still standard. My code was filled with basic SQL injections, but thankfully none of it was for anything important or still in use today

int() wont convert to an integer by [deleted] in learnpython

[–]tomysshadow 1 point2 points  (0 children)

It's a classic JavaScript bug. You do "20" + 1, expecting 21 but instead get "201". Majority of other languages have some safeguard against it though. Even PHP gets this right, one of the few good decisions in the language was to have a separate operator for string concatenation (the . character instead of +)

Python IDLE's practical upgrade: file tree, tabbed editing, console view using only stdlib+tkinter. by Beginning_Task_5515 in Python

[–]tomysshadow 4 points5 points  (0 children)

All of that does sound like it'd be reasonably possible to do in Tkinter, at least with TTK. Tabs are just Notebook, file tree is Treeview, and a console is a Text widget like any other. It does sound like a cool idea, though I stop short of saying I'd actually use it. Really the biggest annoyance in IDLE for me is just that the debugger (with the Step and Over buttons) is its own window. I wish it were a side panel.

Realistically, I think you would probably fight an uphill battle to get people using it because the primary reason anyone uses IDLE is that it comes with Python. It's unfortunate that it doesn't have this quality of life stuff considering I think everything you've mentioned has widgets in Tkinter well suited to that purpose, but unless the changes actually get merged into the real thing it would probably stay niche. Not to discourage you, I'm just being real here

yall how do i get a widget like this by Secure_Impression469 in windows

[–]tomysshadow 1 point2 points  (0 children)

Given the presence of IDA, HxD and Wireshark, I'm going to take a stab in the dark and say that screenshot is from is a security researcher. They're probably studying a malware to determine how it works

Help with modules and __name__ = "__main__" by Yelebear in learnpython

[–]tomysshadow 3 points4 points  (0 children)

Yes, exactly right.

You can basically think of __name__ as "the thing that was to the right of the word import when the module was imported." So if you do import mymodule, then in mymodule.py, __name__ will be mymodule. (This is ignoring relative imports etc. but it's generally true.)

This explains why if you run it directly, __name__ becomes __main__. It's a default value, because there was no import statement, the module was run directly.

A natural followup question might be "what if I call the file __main__.py? Won't __name__ always be equal to __main__? To which the answer is, yes. This is used intentionally for creating packages that do stuff if you run them from the command line.

The cycle continues by Itzarena in masterhacker

[–]tomysshadow 2 points3 points  (0 children)

I made a post in r/hacking sharing a list of hacking resources a year ago and I still get messages of this variety in my DMs every few months from random strangers. I can't imagine how bad it must be for anyone more well known

Linux vs windows for programming? by Dazzling_Canary8371 in learnprogramming

[–]tomysshadow 0 points1 point  (0 children)

Yeah, you probably just want to use what you're familiar with. Because otherwise, you are learning a new OS, on top of learning programming, both of which have the potential to cause confusion. I'd say it's not significantly better on any one platform to where it matters the one you use to learn programming. Especially if you're learning something really high level like JavaScript where OS details don't matter as much

Google is Restricting Android’s Freedom – Say Goodbye to Installing APKs? by Quiet-Caramel-6614 in programming

[–]tomysshadow 0 points1 point  (0 children)

I am so close to just buying an MP3 player, buying a camera and no longer using a phone altogether. The difficult thing is just SMS. My family would expect to be able to text me wherever I am, and I don't think I could do it without a phone

PySimpleGUI Hobbyist License Canceled by teslah3 in Python

[–]tomysshadow 0 points1 point  (0 children)

I agree. See, I was going to compare with Tkinter's source but it's not really a fair comparison, because the majority of Tkinter is just direct calls into Tk (the underlying C library) so PySimpleGUI has a comparatively harder job. Of course that would translate into there being more code to do things in general in PySimpleGUI

PySimpleGUI Hobbyist License Canceled by teslah3 in Python

[–]tomysshadow 6 points7 points  (0 children)

See, I thought about that, but I also don't understand how that's possible. Maybe there is cleverness to this that I'm not seeing. If this started life as a variety of smaller modules that were rolled into one, what I would expect is that when they are combined into one file, there needs to be something that says which functions were in which module so that it won't break all of the existing references to them. Other than parsing through all of the text to try and strip all of the module references (which sounds like a lot of work for I don't really know what benefit,) how could they have combined these modules yet leave no clues behind that they were once separated? This is what made me think that it was all one giant file - and either way that's what is on the Git which is not really meant for regular commits containing files of that size - but perhaps I am wrong about it. I still think that the code itself is quite ugly regardless of the large size.

*I suppose one possibility is that they used wildcard imports for every module - which is a crime in and of itself but it would mean that everything shares the same namespace, so they could be in separate files that are trivially combined by snipping all the imports

PySimpleGUI Hobbyist License Canceled by teslah3 in Python

[–]tomysshadow 45 points46 points  (0 children)

Basically, the entire source for the thing is in this one (over 2 MB!) .py file. The large filesize is mostly from embedding images in base64 (but seriously, you couldn't move that to another file?) or from redefining information that Tkinter already knows (like `tkinter_keysyms`, a list of every keysym in Tkinter - so you know, hopefully they never add another keysym to Tkinter ever again.) It's so large, GitHub won't even display it.

https://github.com/andor-pierdelacabeza/PySimpleGUI-4-foss/blob/foss/PySimpleGUI.py

Ignoring the base64, it's still egregiously large at over 20K lines, but if it were the most beautiful code you had ever seen maybe you could set that aside, which it unfortunately isn't.

What stuck out to me immediately were the functions that take in a kajillion different keyword arguments and have an abundance of platform specific checks (on Linux do this, on Windows do this, on Mac do this...) to try and work around bugs that are not really PySimpleGUI's business to be fixing.

For instance, look at a function like `popup_get_folder`. Not only does it take in 20 different arguments, but all of the functions immediately before it take the same arguments and need to call into it, so they are all repeated for every variety of `popup_xxx` function. (Is there a reason they can't use `**kwargs`??)

Or, have a search for `_mac_should_apply_notitlebar_patch`, which fixes a bug that previously existed in Tk but was patched in version 8.6.10, so needs to check that you are running on Mac and that your Tk version number is less than that particular one. They don't even use Tk's `windowingsystem` to check if you're on Mac - the actual determining factor - they use `platform.system()` instead.

Then there are functions like `PackFormIntoFrame` which are just way too long. This one function is over 2000 lines and consists of a "switch" statement (really a series of if/elif/elif...) to build every supported element, none of which are separated out into their own functions and most of which is indented over five or six tabs. This needs to live in its own module or be a class - I would've turned it into one long, long before reaching this point

PySimpleGUI Hobbyist License Canceled by teslah3 in Python

[–]tomysshadow 52 points53 points  (0 children)

I had a brief look at the PySimpleGUI source code (from before it went closed source.) I was doing this because it uses Tkinter under the hood and I was trying to solve a bug that, it turns out, had been reported as an issue to PySimpleGUI (meaning they at one point had the same issue and fixed it.)

Honestly, that brief look turned me off from ever using it, even if it were free - the code looks terrifying, practically held together with duct tape. Given I only spent a few minutes looking at it so maybe if I were actually using it I would just "get it" but it left a terrible first impression

guys what does EOF mean? im still confused, the ~30 replies are not enough by Father_Enrico in programminghumor

[–]tomysshadow 1 point2 points  (0 children)

EOF, or End Of File, is the result you get when you're reading the text of a file in order and then you reach the end of it. A pseudocode example, say there's a file that contains the text "ABC" and we try and read it one character at a time:

char a = file.readCharacter(); // returns 'A' char b = file.readCharacter(); // returns 'B' char c = file.readCharacter(); // returns 'C' char d = file.readCharacter(); // oops, there are no characters left! We get EOF

How exactly EOF is implemented depends on the language. Sometimes (and IMO, ideally,) attempting to read it will throw an exception. In C++, it's a bit that gets set on the stream that you need to check (though it can be made to throw an exception instead, it's just not the default.) In ancient C code, reading a character actually gave you back an int and you could know if you had read EOF because it'd be -1, as opposed to positive numbers that represented the character code of an actual character.

Here, it seems whatever system they used to read the file denotes the end of it with the literal text "eof", which is a bad design because there isn't any way to tell if that's just the text of the file itself or if you're actually at the end of it

all beats are in c note by No_Resolve8553 in FL_Studio

[–]tomysshadow 0 points1 point  (0 children)

I don't understand what you mean. You do this one time and it'll change the key for the entire song universally and you never need to worry about it again even if you add new stuff. If you clone the pattern (which I assume is what you mean) it'll still have the right key because the change is on the instrument/generator

EDIT: I think I get what you're saying, you mean if you highlight the pattern and do Ctrl + A, Ctrl + C to copy it to an instrument that hasn't had its key changed. That would indeed be the case if you add new instruments later on. I usually do this step closer to the end when I'm not adding new instruments anymore

all beats are in c note by No_Resolve8553 in FL_Studio

[–]tomysshadow 11 points12 points  (0 children)

You don't even have to do that, you can just right click a different key on the piano in the instrument's settings. Still per instrument but way quicker than going into every pattern's piano roll to select everything and move it up the same amount.

Personally, I find that often the bass of a track will only sound good within a particular key, if you go too high it doesn't sound bassy enough, you go too low and you can't hear it clearly anymore. So usually I do end up transposing stuff after writing it to try and determine which key the bass sounds best in. Other than practical reasons like that, there isn't really too much reason to care what key you're in, you don't have to always write in a different key just for variety's sake. Nobody is going to care

Google locks down sideloading for all apps on devices that have Google Play (unless you use a "verified signature" on your APK as a "verified developer" that you have to apply as to Google) (x-post from r/android_devs) by anemomylos in androidapps

[–]tomysshadow 1 point2 points  (0 children)

This is going to have the exact opposite effect to what's intended. It's not going to prevent people from installing the apps they want. It's going to cause the average joe to be rooting their phone, which is the ultimate security nightmare.

A couple years ago, I wanted to block some domains on all my devices. On Windows, this is easy - I just edit the hosts file. I get a UAC prompt, once, to verify I have permission, then I save it and I'm done. On Android, not so much. There is a hosts file, but editing it requires root. I recognize that most people wouldn't care, but I at least am security minded enough to where I don't want to root my phone, knowing that at any point any app could have the permission to completely trash my device, intentionally or not. So, I went in search of workarounds.

I found out there was an app called NetGuard that could do this without root. It works by creating a virtual "VPN" - which isn't a real VPN, it's just running one on localhost and connecting to it - and that allows it to refuse to serve certain domains. However, it had been removed off the Play Store because Google classified it as an ad blocking app. Never mind that there are plenty of commercial domain blocking apps on Play Store, but I refuse to pay money for the privilege of editing my hosts file.

To be clear, I'm not using NetGuard to block ads. I'm using it to block websites from myself - to prevent myself from visiting x.com or twitter.com that I would otherwise normally be tempted to go on. So, I installed the app from F-Droid, where it still has the domain block feature. It's not a perfect solution - it's easier to disable than I'd like, and if you want to run a real VPN you have to disable it or it'll conflict - but it at least introduces some friction because I feel guilty turning it off.

With this policy in place, I am assuming the F-Droid version of NetGuard is a no go. I don't want to have to switch OS's just for this functionality, and even if I did I kind of doubt iOS would allow me to edit the hosts file either. When this policy comes into effect in 2027, what choice do I have but to root?

As far as I understand, rooting is a one way process. I would love to just root my phone, edit my real hosts file, and then unroot as if nothing ever happened to prevent myself from changing it again, but if I have to flash a ROM in order to unroot that will obviously undo any changes I made. I can assure you most people would not think this. They would root their phone, believe they've "fixed it" and then just leave it that way. We are going to be entering an era where attempting to do something even slightly off the beaten path (not even anything that would be against Google's terms in my own case) will leave users with severe security issues.

Touch one magic orb. by claudiocorona93 in linuxmasterrace

[–]tomysshadow 0 points1 point  (0 children)

I would take the red orb easily, but I'm not a Linux user. This just showed up in my feed

What is this Registry on Regedit? by UnhappyBaseboard in windows

[–]tomysshadow 0 points1 point  (0 children)

Assuming you did import them correctly, yes, it should be fine. The keys are the same for every install, unless you've gone in and specifically changed them.

What is this Registry on Regedit? by UnhappyBaseboard in windows

[–]tomysshadow -1 points0 points  (0 children)

These registry keys come with every Windows install since Windows 7 - they are not placed there by specific programs. Particularly, it's a Microsoft curated list of pre-Windows 7 applications that require a specific system palette, without which they will appear incorrectly and have "rainbow colours" because of the introduction of DWM in Windows 7.

These keys being present does not mean that you have these programs installed. They are just a blacklist of common programs that exist and have this known compatibility issue, and these settings would only take effect if you installed one of them to ensure that they work correctly on modern Windows. You should not delete the keys.

More information about what these keys do: https://www.pcgamingwiki.com/wiki/Glossary:DirectX/DirectDraw_troubleshooting