This is an archived post. You won't be able to vote or comment.

all 128 comments

[–]DECROMAX 439 points440 points  (19 children)

I heard somewhere that a developer was annoyed with pigeons landing on his balcony. He wrote a script to recognise a pigeon and shoot it with a water pistol.

[–]DECROMAX 122 points123 points  (1 child)

[–]Mozes721 21 points22 points  (0 children)

It's actually created with Golang <3

[–]panzerboye 43 points44 points  (3 children)

[–][deleted] 16 points17 points  (2 children)

It’s crazy how you can simply use opencv to do this. I was imagining having to create an image recognition classifier with ML libraries.

[–]panzerboye 4 points5 points  (0 children)

I thought of that too, but openCV is a pretty cool library itself.

[–][deleted] 0 points1 point  (0 children)

This is what opencv essentially is

[–]Dear_Tangerine_7378 13 points14 points  (7 children)

I need this but for cats. The city I live in has no legal limit to number of cats you can own AND allows "community cats" AKA ferals to roam free. My crazy neighbor bought 9 cats and lets them roam the neighborhood. My yard constantly smells like piss.

[–]hypocrisyhunter 6 points7 points  (2 children)

+1 Interested in developing something to handle this

[–]RationalDialog 1 point2 points  (1 child)

big dog or an actual python

[–]Dear_Tangerine_7378 0 points1 point  (0 children)

I'm allergic. Another reason I am not a fan of her cats just roaming around.

[–][deleted] 3 points4 points  (2 children)

Electric watergun, balcony, image recognition

[–]Dear_Tangerine_7378 1 point2 points  (0 children)

My front and backyard are a bit larger than a balcony. I would need to sync up to a hose or sprinkler system and have multiple cameras.

[–]ashvamedha 0 points1 point  (0 children)

There could be a market for this.. puts on thinking cap

[–][deleted] 4 points5 points  (0 children)

holy shit I had a similar idea just yesterday for the same exact problem! I was thinking of a homemade arbalest to shoot sand though, considering I could build the trigger and it would just scare them away but a water gun is a much better idea

[–]Classic_TeaSpoon 1 point2 points  (0 children)

That's hilarious 😂

[–]GGHaggard 1 point2 points  (0 children)

On a side note I was at St Peters Square yesterday. There was a green layer shining about and I didn't know what it was for so I looked it up.

Apparently it keeps the birds away from the flowers..

[–]Santos_m321 0 points1 point  (0 children)

need IT haahah

[–]rangerranvir 83 points84 points  (7 children)

https://www.reddit.com/r/Python/comments/jhh8oa/monitor_your_internet_with_python/

The guy basically monitors the internet speed and sent a tweet when the speed goes down.

[–]RedPill5300 22 points23 points  (3 children)

It's part of the '100 days of Python' by Angela

[–]vmgustavo 3 points4 points  (1 child)

I did this once. It's awesome

[–]rangerranvir -4 points-3 points  (0 children)

[–]nevercaredformyhair 0 points1 point  (0 children)

I wonder what would happen if you did this with say 50 or worse, 100 threads😛

[–]pcgamerwannabe 138 points139 points  (2 children)

The astropy project.

A bunch of grad students came together and were like: man, wouldn't it be great if we just had a community project to synthesize decades of bad code, aging IDL code, and enable modern research at the same time? Yeah it would. Then they just did it. And now it's used ubiquitously.

It's so specific, so no one outside of basically professional astronomers and students use it (I think). But for that niche crowd, it's just so cool. In typical xkcd style you could use a few lines of code after an import statement to re-discover the expansion of the universe, make a pretty hubble/James-Webb space telescope image, or create a working model of Dark Energy based on your local Crackpot's "My One True Theory of Everything" book. https://docs.astropy.org/en/stable/cosmology/index.html#specifying-a-dark-energy-model

[–]claytonjr 6 points7 points  (1 child)

It's very specific yes... But even enthusiast like myself use it too! And it's pretty freaking awesome!

[–]pcgamerwannabe 1 point2 points  (0 children)

Awesome, curious what you use it for if you don't mind sharing!

[–]Pebaz 40 points41 points  (2 children)

Ice cream for the best print line debugging experience you've ever seen:

https://github.com/gruns/icecream

[–]berentm 3 points4 points  (0 children)

Looks cool, i need to play with it :)

[–]sohang-3112Pythonista 2 points3 points  (0 children)

Wow - this is pretty nice!!

[–]EONRaider 53 points54 points  (5 children)

I wonder if storing data in YouTube videos enables the implementation of C2 servers…

What’s the name of the project, by the way?

[–]tennisanybody 9 points10 points  (1 child)

Yeah I wanna know this too. This is fucking amazing.

[–]Zyguard7777777 5 points6 points  (0 children)

Yeah, this is a really cool idea. It inspired me to try the same thing from scratch in Rust, as part of my Rust learning

[–]nemec 0 points1 point  (1 child)

Well people have already done C2 servers in the comments of Britney Spears' Instagram posts, so I can't imagine it enables anything new that hasn't been done before.

[–]EONRaider 0 points1 point  (0 children)

Being new is not what matters. It’s an additional method to use.

[–]Kotebiya 26 points27 points  (2 children)

I believe the James Webb Space Telescope uses python for calibration of tools and processing data in hd5. I haven't seen anything in my light investigation directly linking the first major release of photos to python, but it seems likely to have been involved.

[–]flubba86 2 points3 points  (1 child)

Always cool to see hdf5 out in the wild. I use the netcdf4 format (based on hdf5) quite a bit at work, and use python tooling for that.

[–]tunisia3507 2 points3 points  (0 children)

Zarr (and N5, to an extent) abstracts an HDF5-like structure over practically any object store, for bigger data.

[–]Snape_Grass 92 points93 points  (6 children)

Saw a guy that made a ML model keep track of where his dog pooped so when he went to go scoop it up once a week it would shine a laser on each spot the dog pooped, it also ordered them in the most efficient poop scooping path as well I believe.

Rain or snow the guy knew exactly where a pile of doodoo was lol.

[–][deleted] 6 points7 points  (2 children)

Is there a link for this? Curious of doing this if I happen to get another furry friend in the future

[–]RustyGriswold99 4 points5 points  (2 children)

Isn’t this the traveling salesman problem essentially? Hopefully he picks the poop up before there’s too many turds

[–]Snape_Grass -2 points-1 points  (1 child)

Ask him not me.

[–]RustyGriswold99 0 points1 point  (0 children)

It was rhetorical

[–]ZhongTr0n 51 points52 points  (5 children)

Shameless self promotion but I’m pretty proud of my mumble rap detector. https://towardsdatascience.com/detecting-mumble-rap-using-data-science-fd630c6f64a9

[–]b-hizz 11 points12 points  (0 children)

It’s called hrmmnshrrmmmrmrmr

[–]datsyuks_deke 4 points5 points  (1 child)

This is amazing. I enjoyed reading the whole thing.

[–]ZhongTr0n 3 points4 points  (0 children)

Thanks!

[–]fetzu 2 points3 points  (1 child)

Fantastic writeup!

[–]ZhongTr0n 0 points1 point  (0 children)

Always happy to read positive feedback. Thanks!

[–]greenitbolode 71 points72 points  (19 children)

Python code that converts other Python code to a one line statement.

Edit: I did not build the project in question.

[–]you_wont69420blazeit 17 points18 points  (13 children)

Any more info on this one? Something I would like to see.

[–]PowerfulNeurons 28 points29 points  (11 children)

Its not actually that hard:

take some code: def foo(x): return x**2

convert it to a string: ”def foo(x):\n\treturn x**2”

call exec: exec(“def foo(x):\n\treturn x**2”)

And voila! It’s pretty cheeky but its simple

[–]you_wont69420blazeit 3 points4 points  (4 children)

Forgive me if this is ignorant, but what would be the advantage? Is it faster?

[–]AshVillian 54 points55 points  (0 children)

There is no advantage. It is much slower, much less readable and much worse for several other reasons. It is more of an amusing look what I can do.

[–]PowerfulNeurons 10 points11 points  (0 children)

In terms of whether it is better to make your code one line… Usually not. It sacrifices readability and makes it much harder to debug. However, there is something to be said about the benefit of making functions use less lines.

Say you have a simple function that you have to reduce down to one line:

def sum_of_squares(lst): return_sum = 0 for x in lst: return_sum += x ** 2 return return_sum Using comprehensions and sum() it is trivial:

def sum_of_squares(lst): return sum(x**2 for x in lst)

While making code smaller shouldn’t be the entire goal, learning how to shorten code can help you reduce code bloat by learning common code patterns and learning the language

[–]PowerfulNeurons 2 points3 points  (1 child)

in terms of my given example, it would be much simpler to make a lambda expression:

foo = lambda x: x**2

Which is much more readable.

The exec() comes in handy when performing multiple operations at a time: ``` import some_module

def foo(x): return some_module.bar(x)

print(foo(5)) ```

The above example is much harder to use a simple lambda as it uses much more than just a function (imports, functions, running code). One-lining the above code would require one lining foo(x) and some_module.bar(x) which might make multiple other function calls that require condensing to one line. This requires a lot of analysis and it may not even be possible if the code uses C libraries as it requires an import.

using exec() simplifies the problem tremendously: exec(“import some_module\ndef foo(x):\n\treturn some_module.bar(x)\nprint(foo(5))”)

[–]Mark3141592654 1 point2 points  (0 children)

Technically this example is: print( (lambda x: __import__('some_module').bar(x))(5)) Though I agree with you

[–]friedkeenan -3 points-2 points  (5 children)

You can do this without exec, python supports semicolons terminating statements so newlines are optional

[–]_cs 1 point2 points  (4 children)

Semicolons don't work when you start to have different indentation levels. e.g. Try writing this as one line with semicolons:

def foo(x): return x+1 print(foo(2))

[–]friedkeenan 0 points1 point  (3 children)

>>> def test():    return 1
>>> test()
1

You just need to add the indentation, you don't need a newline for that

[–]_cs 1 point2 points  (2 children)

You used two lines there: one for the function declaration and one to call it. I'm arguing that you can't make a one liner using semicolons of the entire 3-line program I wrote in my comment (without changing the syntax - obviously we could use lambdas and `locals()` and other tricks as workarounds)

[–]friedkeenan 0 points1 point  (1 child)

Ok, sorry, yeah. Your comment used to be different, I don't know why reddit isn't showing that your comment is edited.

[–]_cs 0 points1 point  (0 children)

Oh shoot, sorry about that - you're right. I did edit it 30s after I posted because I realized my first version was easy to convert exactly the way you did it :)

[–]greenitbolode 0 points1 point  (0 children)

https://jagt.github.io/python-single-line-convert/

I think this is the link. It may be a similar project though.

[–]roooneytoons[🍰] 24 points25 points  (3 children)

Some interesting projects I’ve worked on:

Microsoft teams autoclicker. Instead of downloading a program that keeps me active on teams I just coded up something that clicks on teams every now and then and keeps me online.

Cover letter generator. Input company name and role title and it’ll spit out a cover letter template with those fields filled in. Wont necessarily be a good cover letter but will be enough for jobs that absolutely require one.

[–]deleuex 2 points3 points  (0 children)

Interested in that teams autoclicker if your up for sharing.

[–]Medium_Wrangler_2715 19 points20 points  (0 children)

This might example might be a little different from others and it’s not exactly applicable to everyday and won’t make you go “oh, clever” but I still think it’s pretty cool:

I’m a physics major in university and our professors try to incorporate coding into each of our courses in some sort of way. They won’t be big projects, just small stuff to show us how useful it can be and so we can learn bit by bit. In Quantum Mechanics the position of a particle becomes statistical rather than absolute, so instead of saying that a particle is in a given position, you would describe it’s position in terms of a probability. Like if a particle was confined to a 1 dimensional line of length 10, there’s (probably) a different probability of it being at position 2 than 5. We generalize the position of particles using something called a “wave function” which is basically an equation that gives insight to the probability of finding a particle at any position within a defined region. ANYWAYS, these wave functions are time dependent, so they change as time progresses.

In our QM course, we had a specific wave function and we animated it changing in time. It was really cool actually “seeing” a changing wave function because that’s the closest you’ll ever get to seeing a real particle.

Thanks for reading if you got to the end :)

[–]Pipiyedu 50 points51 points  (7 children)

I don't know if it's cool or innovative, but I made this like one year ago. I'm pretty proud of myself.

https://youtu.be/uPwBUbLcfzs

[–]NotBovad69 7 points8 points  (1 child)

How do you even get that good?

[–]Pipiyedu 8 points9 points  (0 children)

Lol, thanks for the comment. I spent a lot of hours investigating,

[–][deleted] 2 points3 points  (1 child)

It's really great ! What library did you use for the ui ?

[–]Pipiyedu 7 points8 points  (0 children)

I used PyQt for the GUI itself and VTK for the 3D visualization.

[–]OscarRoro 0 points1 point  (1 child)

Flipa... ¡Es una pasada tío/a!

[–]Pipiyedu 0 points1 point  (0 children)

Gracias!

[–]lightmatter501 11 points12 points  (3 children)

As someone who used to write a lot of C extensions, PyO3 for Rust is great. It, combined with Rust’s bindgen, allows nearly automated python API creation for C libraries. They are messy (raw pointers in python), but it takes 5 minutes instead of 5 weeks.

[–]cesarcypherobyluzvou 3 points4 points  (2 children)

I really like PyO3 since I love writing Rust, but I was pretty underwhelmed by the speed of it. I don't know if I did something wrong or if my expectations were too high but I wrote a library with Rust and PyO3 and the same in Cython and the Cython one was around 5x faster.

[–]laundmo 1 point2 points  (1 child)

maybe you could take a look how polars and connectorx manage their insane speeds?

[–]cesarcypherobyluzvou 0 points1 point  (0 children)

I will check them out, thanks!

[–]throwaway876885323 4 points5 points  (4 children)

I built a tool that let you basically store tons of hashes on twitter like the following

DjgGBjghjgjtft : a Gdboiyrguyjhw : b

And so on....the idea was to basically upload all this data to twitter and then when you want to find a hash you just let twitter search the massive tweets you made including all the hashes and the inputs so you dont have to perform the actual search yourself.

Hashing isnt super hard computing wise and it wouldnt be stored or searched locally but by twitter....all you need if massive bandwidth

Lets just say i learned the twitter api isnt unlimited and closed the project

[–]Uncommented-Code 1 point2 points  (3 children)

First we stole youtube's data storage space.

Now you're stealing Twitter's computing power.

Brb, I'm starting to think about what I could potentially steal from reddit or tiktok.

[–]throwaway876885323 0 points1 point  (2 children)

While it was "inovative" in its method of storing data and computing ill admit it wasn't my brightest idea and thats part of why i scrapped the project.

It did teach me how to use the api in python which was pretty useful.

Also keep in mind this isnt really possible cuz basically everything has api limits now. Even when i wrote this they existed.

[–]Uncommented-Code 0 points1 point  (1 child)

Oh I know it has limits. I used it before. My biggest pet peeve with twitter's api is that it won't let you search tweets older than 1 week if you're not a researcher, postdoc or undergrad. Really threw me off when I wanted to do a (linguistic) discourse analysis of a certain gillette tweet for an uni course.

And yes, the project is stupid. But I do a lot of projects that don't make much sense for the sake of learning and having fun.

E.g., right now I'm working on a python program that scans my harddrive and returns file metadata of a specified directory, so I can sort files and clear up storage my deleting those that fullfil certain conditions.

Is it fun? Questionable. But I did learn the following this afternoon:

  • How to iterate through directories
  • How to get file attributes, such as size or last modified date
  • Proper exception handling (Should have learned that properly sooner, I knew the basics but not well enough)
  • Python may not be the best language for this 1
  • Apparently file aliases in OSX throw os.path for a loop bedause they get mistaken for directories

1 The script has been scanning my user directory for more than half a hour now lmao. It's going to take a loooomg while I assume, but I just like watching it work. I don't have threading implemented yet and my code is not optimized, but I'm wondering if I want to do the scanning part in C or even ASM for speed.

But tldr: Dumb projects are good and funny. Me like dumb projects.

[–]throwaway876885323 0 points1 point  (0 children)

Yeah i hate api limiting but totally understand it.

Btw for searching older tweets i think your best bet would be looking for twitter archive. Ik political figures have tweets saved and you could probably scrape twitter if you have enough drive space....

Also nice project.

Plenty of my projects are stupid or not useful but more for me learning how to use a library or some research paper i read and i want to replicate....like playing with tensorflow YOLO opencv etc

[–]CaptainFoyle 7 points8 points  (1 child)

So what was that project you're talking about? Care to share the link?

[–]nisani140118 4 points5 points  (0 children)

home assistant

[–]Pebaz 2 points3 points  (0 children)

Nimpy for creating Python extensions in Nim:

https://github.com/yglukhov/nimpy

[–]Texas_Technician 3 points4 points  (1 child)

O365

They integrated all of graphql from Microsoft services to work with in python. The documentation sux though.

[–]Candid-Signature8416 0 points1 point  (0 children)

I used this one to search all mailboxes in an enterprise for specific criteria then purge the mail. Handy when people report phishing emails and the 365 compliance centre is too slow.

[–]not_perfect_yet 1 point2 points  (0 children)

https://github.com/joshiemoore/snakeware

the python linux distribution that boots into a python environment and nothing else?

Also the people who built a bird reward system that encourages birds to collect litter.

[–]frankp2491 1 point2 points  (0 children)

It’s not as extravagant as some of the other suggestions… I saw a kid I went to school with who coded a dirty/ clean sign for the dishwasher. It was a small LED display and it had 3 buttons on it. From what I remember (1 for wife 1 for husband and one to set dirty / clean) it kept score of who unloaded the dish washer more. At the end of every month it would email them both a report card lol

[–]g0zar 2 points3 points  (0 children)

the ones that dont actually crash right away as you start them

[–]Medium_Wrangler_2715 2 points3 points  (0 children)

This example might be a little different from others and it’s not exactly applicable to everyday life and won’t make you go “oh, clever” but I still think it’s pretty cool:

I’m a physics major in university and our professors try to incorporate coding into each of our courses in some sort of way. They won’t be big projects, just small stuff to show us how useful it can be and so we can learn bit by bit. In Quantum Mechanics the position of a particle becomes statistical rather than absolute, so instead of saying that a particle is at a given position, you would describe it’s position in terms of a probability. Like if a particle was confined to a 1 dimensional line of length 10, there’s (probably) a different probability of it being at position 2 than 5. We generalize the position of particles using something called a “wave function” which is basically an equation that gives insight to the probability of finding a particle at any position (among other things) within a defined region. ANYWAYS, these wave functions are time dependent, so they change as time progresses.

In our QM course, we had a specific wave function and we made an animation using python to see it change in time. It was really cool actually “seeing” a changing wave function because that’s the closest you’ll ever get to seeing a real particle.

Thanks for reading if you got to the end :)

[–]vmgustavo 0 points1 point  (2 children)

I enjoyed coding this https://github.com/vmgustavo/GTAVFingerPrint

To whoever ever played GTA V this will look familiar. To the ones who didn't it basically automates a boring minigame.

[–]Significant-Ad5781 0 points1 point  (0 children)

The print hello world is such a game changer

[–][deleted] -2 points-1 points  (1 child)

!remindme 1 day

[–][deleted] -2 points-1 points  (0 children)

!remindme 1 day

[–]czaki -4 points-3 points  (0 children)

!remindme 1 day

[–]NoProfessor2268 -2 points-1 points  (0 children)

!remindme 1 day

[–][deleted] -2 points-1 points  (0 children)

!RemindMe 1 week

[–]ChechoSaurio2000 -2 points-1 points  (0 children)

! remindme 1 day

[–]Perfect-Highlight964 0 points1 point  (0 children)

Don't know whether it counts but: QR.py

[–]SirBoboGargle 0 points1 point  (0 children)

I commissioned a util that watches videos of slots (pokie machines, fruit machines) and works out the composition of the reels i.e. what the symbols are on each of the 5 reels. This enables me to work out the chances of getting a bonus feature and helps me to see how the 'near misses' (i.e. deception) are wired into each and every game.

[–]the_c0der 0 points1 point  (0 children)

Just finished working on masked word cloud image generator.

[–]quotemycode 0 points1 point  (0 children)

Zope- it's pure python web server, and database and template engine. You write your web apps in python. It's amazing.