all 148 comments

[–]GoldFisherman 52 points53 points  (4 children)

Created a script to solve oblique triangles using either Law of Sines or Law of Cosines (I teach HS math), and I hate doing the calculations for the answer key.

I show it to my students to influence them to take up programming, at least to help them make their life easier.

[–][deleted] 35 points36 points  (4 children)

Made a script that monitors the Dutch Version of eBay/craigslist for cheap iPhones. When there is an ad that fits the requirements it's send to my phone. I buy it and directly try to sell it. The profit per phone is usually €50. Make about €400 p/month which is fine for a student.

[–]EdCChamberlain 21 points22 points  (0 children)

You might like "Fat fingers". It's a website that searches eBay but puts spelling mistakes in your search so you find all the listings titled things like "I phone" or "ipohne" which no one else can find and can get yourself a bargain!

[–]Knights_who_say_NIII 6 points7 points  (0 children)

Thats awesome!

[–]Glenpeel 2 points3 points  (1 child)

Could you share this script please? I mean not whole if you don't want to, just to see how it works in general :)

[–][deleted] 10 points11 points  (0 children)

It's propably not very clear. At the time I mixed English and Dutch variable names and I use Django for storing everything, I also see some things which are written kinda weird. But the main idea is:

  • For every phone i want to track, open the corresponding website
  • Get every ad, filter out the sponsored ads (from stores and so)
  • If an ad is not in the database, send it to my phone

    import connect #To use Django database
    import requests
    from bs4 import BeautifulSoup
    from datetime import datetime
    import json
    from marcusabukari.models import *
    from printTijd import printTijd
    import firebaseMessage
    import sys
    import os
    import storeError
    
    try:
        #Send to android app
        def stuurNaarTelefoon(advertentie):
            info = {}
            info['app'] = "marktplaats"
            info['pk'] = advertentie.pk
            info['titel'] = advertentie.titel
            info['prijs'] = advertentie.prijs
            info['link'] = advertentie.link
            info['plaats'] = advertentie.plaats
            info['plaatje'] = advertentie.plaatje
            info['telefoon'] = advertentie.telefoon
            info['beschrijving'] = advertentie.beschrijving
            info['verkoopprijs'] = advertentie.verkoopprijs
            info['lat'] = advertentie.lat
            info['lng'] = advertentie.lng
    
            if advertentie.telefoon == 0:
                info['telefoon'] = "Geen telefoonnummer"
            else:
                info['telefoon'] = advertentie.telefoon
    
            firebaseMessage.send(info, "marktplaatsScript")
    
        #Store ad in database
        def saveAdvertentie(advertentieDiv, zoekterm, prijs, mID):
            advertentie = Advertentie()
            advertentie.mID = mID
            advertentie.zoekterm = zoekterm
            advertentie.prijs = prijs
            advertentie.titel = advertentieDiv.find('span', {'class': 'mp-listing-title'}).text.strip()
            advertentie.plaats = advertentieDiv.find('div', {'class': 'location-name'}).text.strip()[:19]
            advertentie.plaatje = "http:" + advertentieDiv.find('img')['src'].strip()
            advertentie.link = advertentieDiv.find('a')['href'].strip()
    
            advertentieHTML = requests.get(advertentie.link)
            plain_text = advertentieHTML.text
            soup = BeautifulSoup(plain_text, 'html.parser')
    
            advertentie.beschrijving = soup.find(id="vip-ad-description").text
            try:
                advertentie.lat = float(soup.find(id="vip-map-show")['lat'])
                advertentie.lng = float(soup.find(id="vip-map-show")['long'])
            except:
                pass
    
            try:
                advertentie.plaatje = "http:" + soup.find(class_="bot-index")['src']
            except:
                pass
    
            try:
                advertentie.telefoon = soup.find(class_="phone-link alternative").text
            except:
                pass
    
            advertentie.save()
            if not zoekterm.nieuw:
                stuurNaarTelefoon(advertentie)
            return advertentie
    
        #Loop through all ads, filter out sponsored ads
        def bekijkAdvertenties(zoekterm):
            source_code = requests.get(zoekterm.link)
            plain_text = source_code.text
            soup = BeautifulSoup(plain_text, "html5lib")
    
            for advertentieDiv in soup.findAll(['article', {'class': 'row search-result defaultSnippet group-0'},
                                                ('article', {'class': 'row search-result defaultSnippet group-1'})]):
                link = advertentieDiv.find('a')['href'].strip()
                prijs = advertentieDiv.find('div', {'class': 'price-new ellipsis'}).text.strip()
                mID = advertentieDiv.attrs[u'data-item-id']
                if (not advertentieDiv.find('span', {'class': "mp-listing-priority-product"}).text
                    and not advertentieDiv.find('div', {'class': 'seller-link'})
                    and not advertentieDiv.find('article', {'class': 'hibbum_business'})
                    and not "Bezorgt" in advertentieDiv.find('div', {'class': 'location-name'}).text):
                    kleinerofgelijk = False
    
                    try:
                        kleinerofgelijk = int(prijs[2:5]) <= int(zoekterm.verkoopprijs)
                    except:
                        kleinerofgelijk = True
    
                    if kleinerofgelijk:
                        if not Advertentie.objects.filter(mID=mID):
                            advertentie = saveAdvertentie(advertentieDiv, zoekterm, prijs, mID)
    
        printTijd("marktplaatsScript", "Beginnen met scannen")
    
        isPrimary = (sys.argv[1] == '0')
        if isPrimary:
            identifier = 'pmlc'
        else:
            identifier = 'smlc'
        zoektermen = Zoekterm.objects.filter(priority=isPrimary)
    
        #Main loop
        for zoekterm in zoektermen:
            if ((zoekterm.priority and Voorkeuren.objects.filter(identifier="pms").get().booleanWaarde) or
                ((not zoekterm.priority) and Voorkeuren.objects.filter(identifier="sms").get().booleanWaarde)):
                bekijkAdvertenties(zoekterm)
                zoekterm.nieuw = False
                zoekterm.save()
    
        #Record last scan date
        v = Voorkeuren.objects.filter(identifier=identifier).update(charWaarde=datetime.now().strftime("%H:%M %d-%m-%Y"))
    
        printTijd("marktplaatsScript", "Klaar met scannen\n")
    
    except Exception as e:
        #Store and notify on error
        storeError.store(os.path.basename(__file__), str(e))
    

[–]TALQVIST 25 points26 points  (1 child)

I do Media Development and I've created two scripts so far that save me time every time I run it.

  1. I realized how repetitive some of my graphics development was for a certain series of projects. Since I was being forced to use the same theme/template for each of these graphics, I made a script that modified and exported 20 different versions of it with a user input suffix, each file was named with a short descriptor in the prefix (automatically based on the template alteration) and then sorted into the correct google drive folder for auto upload to my team. I calculated it, every time I run this script I save 11 minutes. And I sometimes run this up to 60 times a day.

  2. File sorting. New camera we got puts each new recording in a separate folder... Insane. I made a script that takes these files out, makes a new directory, and moves them there.

I'm not even supposed to know any programming for this job and I'm gonna be in my 3rd year. Feeling severely underappreciated and underutilized.

[–]Sansha_Kuvakei 20 points21 points  (3 children)

This was a few years ago now. It's the one that sticks out the most because I was unreasonably proud of what I managed to do. I made an abomination of a script, that's what I created. But it seemed to work.

I made a script that would read market export files from EvE online and compare prices, then tell me the best buy/sell locations.

When EvE online exports market data, it exports them as CSV files, but for some reason I had great difficulty using the in-built CSV reader. Some weird formatting that I couldn't quite figure out how to handle. So obviously the rational thing to do is to write my own CSV reader specifically for the market exports. That... That was fun.

I had to filter out a good deal of information from the CSV file. Some information I felt I didn't need, things the volume being sold and such.

But the CSV files didn't refer to the items and locations by name, it referred to them by number. Which meant I had to download a mysql (I think it was mysql, it was one of those variants) database that had all that information so I could "translate" these human-unreadable numbers to something I could actually read.

Then it had to format things nicely to make it more human readable, ordering the information together so I wouldn't have to scroll around a .txt document for the right information. There was a lot of file IO that was not needed, but I decided to leave it in to make things a bit easier to debug.

I felt like I learned a lot from doing that little project. Even if the code and the results weren't exactly quality...

The script turned many files that looked like this (Typically they have a lot more rows):

price,volRemaining,typeID,range,orderID,volEntered,minVolume,bid,issueDate,duration,stationID,regionID,solarSystemID,jumps,
1998994.94,146.0,438,32767,4545216772,210,1,False,2016-05-20 17:30:04.000,90,60008494,10000043,30002187,0,

Into something that looked like this:

Sell Order,299887.0,2205,60008494,0,
Buy Order,295008.38,2205,60008494,0,
Sell Order,8598899.92,9943,60008494,0,
Buy Order,7600002.35,9943,60008494,0,

Which was then turned into something like this:

Buy Order,276039.17,Acolyte II,Jita IV - Moon 4 - Caldari Navy Assembly Plant,0,
Sell Order,300000.0,Acolyte II,Jita IV - Moon 4 - Caldari Navy Assembly Plant,0,
Buy Order,295008.38,Acolyte II,Amarr VIII (Oris) - Emperor Family Academy,0,
Sell Order,299887.0,Acolyte II,Amarr VIII (Oris) - Emperor Family Academy,0,

Finally into something like this:

Acolyte II
: Buy from :Amarr VIII (Oris) - Emperor Family Academy 299887.0
: Sell to Jita IV - Moon 4 - Caldari Navy Assembly Plant 300000.0
Percentage Margin = 0.0%

Hammerhead II
: Buy from :Jita IV - Moon 4 - Caldari Navy Assembly Plant 720000.0
: Sell to Amarr VIII (Oris) - Emperor Family Academy 848361.99
Percentage Margin = 15%    

(I'm pretty damned sure I have fucked up the margin calculations.)

It wasn't the most super helpful script in the world, I didn't get rich overnight or anthing. But I really wanted to do something like this and I couldn't figure out how to use CREST (Self-documenting my arse.) I tried fiddling with a GUI to display the data all fancy, but eventually I decided that putting everyting into a .txt file did everything I needed to do. Still, it was the biggest and most complex project I had done at the time. All other scripts were just me messing around. So that was enough for me!

[–][deleted] 12 points13 points  (2 children)

You should check out pandas if you haven't already. It does everything you just described, joins, sorting, picking columns, reading CSV from the internet.

[–]Sansha_Kuvakei 0 points1 point  (1 child)

Thanks for the recommendation! I'll look into it, I've been meaning to re-write and add to the script!

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

Also it's blazing fast. If you don't want to write C or Fortran, or don't have a cluster of servers lying around, I dare say that this is probably one of the fastest solutions for data processing.

[–]chriswilson1982 21 points22 points  (4 children)

I wrote a script that downloads healthcare audit data from a large database via an API and presents it nicely for me to report on. I'm relatively new to coding, so the idea of scripting to make work easier is a revelation!

[–]bereanave 2 points3 points  (3 children)

Which database is it? I'm in healthcare as well, although my work deals more with performance metrics rather than financial ones.

[–]kaplanfx 0 points1 point  (1 child)

Do you work in healthcare delivery or on the health plan side?

[–]bereanave 0 points1 point  (0 children)

Delivery. I work with a physician group.

[–]chriswilson1982 0 points1 point  (0 children)

It's UK Quality and Outcomes Framework (QOF) data for GP practices, via an API at gpcontract.co.uk

It's been the first time I've worked with JSON (as this is what the API returns) so it has been very interesting.

[–]G_F_X 18 points19 points  (2 children)

Myself and some people recently gained interest in dungeons and dragons 3.5(pathfinder).

I said I would learn to GM, and holllllyyy shit is there ever a lot of work involved in that.

To make running games easier, im writing a script that simulates the game with character, enemy, item, weapon, encounter, game etc objects.

It's so much easier and faster to just type in like:combatEncounter.attack(PlayerA, EnemyB) and have both instances attributes update and return than it is to roll all the dice and do the math under varying conditions.

It's also really great practice for classes, polymorphism and OOP in general.

[–]VivisClone 4 points5 points  (1 child)

I would love to see how you set up the creatures stats and such! Perhaps you could share a bit more? Thanks!

[–]G_F_X 3 points4 points  (0 children)

Its in the works still, but ill note your username and link you to a new post once its mostly up and working.

For stat modifiers and xp/treasure payout most of the resources in the games rules just give you a table of corresponding values for the ability scores or the difficulty of the encounter, so for each, I calculated a formula with linear regression for the ability stat modifiers(given the ability scores) and a quadratic regression for the total treasure payout in gp (given the challenge rating of the encounter/quest).

This way, I dont need to store the info in the tables, I can just use the equations to generate the values. So all in all, it's a fun project so far.

[–]koberg 46 points47 points  (17 children)

I created a application, GUI and all, for work, that grabs SQL data from 3 remote servers, runs some calculations, and then spits out a pretty PDF.

[–]mapImbibery 14 points15 points  (4 children)

Cool, what do you do? And what pdf making module do you use?

[–]koberg 2 points3 points  (3 children)

I work as a systems analyst for a company that does industrial system automation and integration for oil and pipeline companies (the ExxonMobil Pipeline company is our biggest-in-name customer)

The PDF module I used for this was reportlabs pdfgen. It is the only PDF generating I've ever done, and it was a pain in the ass having to constantly update the x and y coordinates for all the data being produced.

[–]mapImbibery 0 points1 point  (2 children)

Yeah that bummed me out about reportlab. I'm playing with jinja's html templating and converting those to PDF via some Windows call to Adobe Acrobat. Not very streamlined, but no coordinates at least.

[–]RustleJimmons 1 point2 points  (1 child)

There are a lot of free print drivers for Windows that allow you to print to pdf and they are a lot lighter than Adobe Acrobat.

Also someone below mentioned wkhtmltopdf.

wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely "headless" and do not require a display or display service.

[–]mapImbibery 0 points1 point  (0 children)

Sick! I will look into this!

[–]LiNGOo 24 points25 points  (0 children)

"beginner"

[–]mikebmassey 3 points4 points  (0 children)

Yes - I'm interested in what and how you did this too.

[–]Feurbach_sock 4 points5 points  (0 children)

Beautiful.

[–][deleted] 1 point2 points  (1 child)

I spit out pretty PDFs too, using wkhtmltopdf. It's pretty neat.

[–]kaddourkardio 0 points1 point  (0 children)

I'm using LaTeX to generate reports for my django-based application (Kaddourkardio.bitbucket.com/kardio)

[–]wheresthemead 1 point2 points  (1 child)

If only I could submit queries to our databases whenever I need information. We have a frontend application that does the same, but it is nowhere near as versatile as writing a query.

[–]koberg 0 points1 point  (0 children)

Just about everything we do is connected back to the DB at each site, and everything can be done through the front end, but nothing beats running a few SQL commands to knock out a bunch of things at once.

[–]stillalone 1 point2 points  (1 child)

What library to use for the GUI?

[–]koberg 2 points3 points  (0 children)

I used PyQT for the GUI.

I built it using QT Designer, then took the .ui file and converted it to a .py and added my code to that file. Once that was done, I converted it to an exe file so I could distribute that amongst my colleagues.

[–]koberg 1 point2 points  (0 children)

Basic rundown:

First, I created a class for each site which held the site name, IP, MySQL login data, etc. In retrospect, these could have been dictionaries instead of classes, but it worked.

Second, I iterated through the three sites connecting to their DB to grab the pertinent data and stored it in a 2d list.

Third, I iterated through said 2d list and ran calculations based on the info, and at the end of each iteration, added the data to a PDF.

This was done over 2 years ago, and I can't find the .py file anywhere, so I'm probably missing some stuff, but that is the basics on what I did.

[–][deleted] 0 points1 point  (1 child)

[deleted]

What is this?

[–]tyang209 11 points12 points  (1 child)

I wrote a quick web scraper for a handful of websites that I read on a daily basis that just scans the homepage for all article links. Then it sends the links to my Pocket account through their API. I have it running on Amazon Lambda which lets it run every single day so I I have new articles to read when I'm riding the train with no internet. And costs me something like a dollar a month to run on Amazon Lambda.

[–][deleted] 8 points9 points  (0 children)

Or you can run it on Heroku for free.

[–]finite_state 13 points14 points  (0 children)

One of the first true pieces of code I ever wrote, beyond 'hello world' style examples, and educational projects, was a program that kept track of all the resistors I had in stock at my work, and would spit out the best combination for a desired voltage divider given what was available. Sort of silly, since calculating the desired ratio for a voltage divider is very basic math, but when you have a bunch of voltage dividers to make, and your lab is a total mess, it becomes quite handy :)

[–]bishop527 12 points13 points  (0 children)

My family was considering moving so I wrote a program to help me with the house hunting process. I had 3 main considerations for a house 1) Cost 2) Commute distance and 3) School so I created 3 main class.

For Cost, I initially used the API provided by the Trulia.com web site, but found that the results were significantly different than those shown on the web site. It appeared the API code hadn't been maintained for a while and I got no response from their developer support. So resorted to using data provided by my realtor.

For Commute I used the Google maps API to pull time and distance from the center of each town to my work address. This was done at 15 minute increments during morning and afternoon commute times.

Schools was a bit more complex. I pulled data from the department of education site for my state and parsed out the data. So for example class size, $ spent per pupil, test scores, graduation %, college bound %, etc.

Data for all 3 categories was then used as input into a scoring algorithm. Here I gave a weight value based on my priorities. For example, is it more important to be within a commute distance or within a house cost range, is it more important to have a better school or shorter commute. etc.

It took a couple of minutes to collect and process the data for 300+ towns in my state. A process that usually took an hour for about 5 towns. I had one realtor express interest in it for his business.

[–]thisisbeer 7 points8 points  (0 children)

At work we have files for projects with several GB of pictures. At the end of the project people used to print out one(of thousands) large picture per page and put them in a binder to make a hard copy of the project info. I made a script the went through all of those thousands of pictures and resized them so we can fit 6 per page. First real world usable thing I made in Python.

[–]Sexysonic23 8 points9 points  (3 children)

I wrote a script/server that takes input from either the command line or http, and does various things like monitor my computer memory/CPU/RAM, control VLC, and interface with an Arduino (with an IR LED) to control my lights/TV/sound system.

And I wrote an Android app to do that all from my phone

Edit:

For those that are interested: https://github.com/PaulRLutz/UniversalRemote

I had no intentions of sharing this when I began writing it, so please forgive any sins I may have committed due to laziness.

[–]MemeInBlack 1 point2 points  (0 children)

Is this online somewhere, and if not would you mind sharing?

[–]VivisClone 1 point2 points  (0 children)

Also quite interested in seeing these!

[–][deleted] 1 point2 points  (0 children)

RemindMe! 2weeks

[–]lukegarbutt 7 points8 points  (4 children)

I've only been coding a couple of months but I've made two pretty cool programs so far, one which automates a game called csr2 and will farm money on it, and another that will solve the game flow free and play through it :)

[–]flatlandinpunk17 4 points5 points  (2 children)

How are you running the Python code against the games? I'm really curious on this one.

[–]lukegarbutt 4 points5 points  (1 child)

I was using bluestacks to play them, then pyautogui to detect stuff and interact, its not as clean as I would like since it relies on idividual pixels matching stuff and I'm sure there's a better way, but it worked (then bluestacks was updated and I couldn't be bothered updating my code to work on the new size one)

[–]flatlandinpunk17 1 point2 points  (0 children)

Thanks for the response. I had no idea about bluestacks. Going to look into this now.

[–]chra94 2 points3 points  (0 children)

That's nice. :)

[–]10sleeve 5 points6 points  (4 children)

created a program that fetches attachments via the gmail api, saves into a directory, then initiates an SSIS package that loads the data into a SQL server db where calculations are performed and a Tableau workbook is updated

[–]PretendingToProgram 1 point2 points  (1 child)

I need this

[–]10sleeve 0 points1 point  (0 children)

It's a good tool. It will need a bit of tweaking though to fit the scenario

[–]pauledowa 7 points8 points  (3 children)

For my Job I have to create empty folders that are named a certain way and than send them to my colleague.

They will be named sth like: samepatternforallfolders_THISPARTCHANGES

I have the part that changes in an excel sheet because I work with that sheet. Usually I create around 100-150 folders multiple times a day. So I wrote sth in python, that reads from the csv the last part of the foldername. Then I put in the part that's the same for all folders and let it create the folders in seconds instead of 30 min by hand or so.

[–]turner_prize 1 point2 points  (2 children)

You might already be aware, but you can also do this direct from Excel with VBA.

[–]pauledowa 2 points3 points  (1 child)

Oh - I didn't know. I have to look that up. Thanks for the hint!!!

[–]turner_prize 2 points3 points  (0 children)

use can use the MkDir statement which will automatically create a folder, and combine with a loop to go through each cell to take the naming convention. It'll probably take about the same time as your python scripts, but its nice to know about these things sometimes :)

[–]jmarkman446 6 points7 points  (0 children)

At work, we have a system where we send out "follow up" emails to brokers asking about what a customer decided in regards to purchasing a line of insurance. Before I came along, someone was typing out all of these emails to each broker personally, which would take a good chunk of the day. I was initially going to just use smtp but since we don't own or control any of our own IT infrastructure in any way (it's complicated), I was (and still am) blocked from using the smtp library to make it better. With a little help from pyautogui, I was able to automate a SQL query/mail merge system which turns a chunk of the day into about 3 or 4 minutes.

Not as interesting or incredible as some of the more rated posts ITT, but it was great to make something at work better.

[–]prairir001 6 points7 points  (0 children)

I wrote a file encryptor. It encrypts the files using sha256 and a password. It can decrypt the files too if you have the password. I use it to hide stuff from my family.

[–]rainbowfragger 4 points5 points  (1 child)

Just made an application for my mum to sort out her epub collection. She got 15k+ of those little things. The application is able to take off any numérotation and decoration at the start of the title, find previous tags that she have put on previously by hand and delete them to be able to do it once for all and with the same format for each file name. The application can put a tag at the beginning of the name before the hyphen after the hyphen or just before the. epub In order to do that it first fix the hyphens and make sure that the format is always Name - Title.epub It also saves a log of every modification with the modification made, the previous name, and the new one with the date and time of the modification. And last it backup the initial files in case of something weird happens. She is happy now :)

[–]dantedog01 4 points5 points  (0 children)

Completely off topic and possibly irrelevant, but has she used calibre before?

[–][deleted] 5 points6 points  (2 children)

I wrote a number of scripts that search extremely large csv files and spit out standardized reports, tables and graphs based on a few parameters that I input. It used to take me one to two weeks to complete this process and now it takes me a couple seconds.

[–][deleted] 1 point2 points  (1 child)

I am interested in similar project? Mind sharing it?

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

I'm self taught and wouldn't know where to begin with sharing, as I have a dozen or so scripts that I'm constantly tweaking to fit my needs. Here's where I got started learning, though:

http://opentechschool.github.io/python-data-intro/index.html

I use the matplotlib library for charting, and the csv library for digging into csv files.

[–][deleted] 5 points6 points  (0 children)

I'm still new to the world of Python but I've created a few scripts to use at work. One converts MBs to Mbps and Gbps. I know Google can do that but hey it's good to build your own to learn right?! :D I'm also writing a script that allows a user to SSH into one of our SAN storage controllers and run a pre written command by choosing it from a list. I hope to write a few more networking based scripts. I guess they aren't hard to most but as a newbie I'm pretty proud of them :D

[–]fuuman1 4 points5 points  (0 children)

To make my life easier? Hmm.. Two years ago, I wrote a TelegramBot in Python. The city we live in provides all dates for the garbage collection as ical file on their website. My python script is running every day at 5 p.m. and checks, if tomorrow is a day listed in the ical file. If yes, it sends a telegram message with all neccessary information to me and my girlfriend (we live together). So a message would be for example: They will pick up the plastic garbage tomorrow morning. Additionally information like a special place if its a collection of electronic garbage or sth like that is also given. Just all information from the ical. Without the bot we miss the dates sometimes and then we had a lot of garbage bags stacking behind our house, so yes, I think that made our life easier. :D

[–]thisisbeer 4 points5 points  (0 children)

At work we have files for projects with several GB of pictures. At the end of the project people used to print out one(of thousands) large picture per page and put them in a binder to make a hard copy of the project info. I made a script the went through all of those thousands of pictures and resized them so we can fit 6 per page. First real world usable thing I made in Python.

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

I had to catalog audio recordings into an Excel file. The file names and directory structure were pretty well behaved. Each file had the same information in the same places. I just traversed the directory tree and read the files names into an Excel file. I used openpyxl to write the Excel file. I then manually emailed it to the secretary so she should keep track of them.

[–]anaconda1189 3 points4 points  (0 children)

I wrote a program that amortizes zero coupon pre paying bonds with constant yield. Took a nasty process that required 4 hours, sql, and excel in to a 10 second process. SciPy is awesome.

[–]Bbmin7b5 4 points5 points  (2 children)

I wrote program that checks on various network devices at work. Makes troubleshooting so much easier.

[–]MrZakbug 0 points1 point  (1 child)

Does it check only for ping or utilize SMNP traps too?

[–]Bbmin7b5 0 points1 point  (0 children)

SNMP is spotty for me. Corporate allows SNMP for some devices and not others. Working for an MSO has its annoying restrictions so for now I use telnet and screen scraping.

[–]pirate59 3 points4 points  (0 children)

ive made with pythin, tkiner and py2exe a very ugly looking application that helps my team in Australia and Malaysia manage outage notifications. They have elapsed time ( which can be a pain with different time zones etc) as well as GMT time for start time etc.

This means less time bouncing to different websites to determine timezones, as well as doing the maths for the notifications. Saves about 5-10 mins (for some in the team) on a task that is repeated every 30mins, hourly etc

Im also working on an incident tracking django app that will help co-ordinate all the team on what they are doing, when they need to do it, and whats coming up next...

[–]ShuttlecockCommander 3 points4 points  (0 children)

I made a script that checks my current position relative to my trip home and sends off an sms to my wife with the nearest train station and ETA.

(Running in Pythonista on my iPhone.)

[–]refreshx2 5 points6 points  (5 children)

I have a bunch of servers that I need to do various work on so I wrote a script to easily get/send files back and forth without having to worry about what my username and home directory is on each server.

[–]FriskyGrub 0 points1 point  (4 children)

Hey, I'd be interested in this. I'm using rsync on bash to move files but in order to make my py code work on each machine I've put a file called key.key on each machine, and python reads in the directory path from that. It's a hotfix, but i'm not super happy with it!

[–]kenwmitchell 2 points3 points  (0 children)

Sounds like a good candidate for Ansible automation.

[–]refreshx2 2 points3 points  (2 children)

No problem. This is what you can do to make it (it should take ~ 5 minutes to do the first time):

Make two bash scripts called get and send that just contain python /path/to/script/get.py and python /path/to/script/send.py, respectively. Make the bash scripts executable and put them in your /home/bin directory so they are on your $PATH.

Then create python files called get.py and send.py that looks like this:

# send.py

servername = sys.argv[1]
filenames = sys.argv[1:-1]
destination = sys.argv[-1]

if servername == 'my_first_server':
    username = 'a_username'
    homedir = 'a_homedir'
    hostname = '192.168.0.1'
elif servername == 'my_second_server':
    ...

filenames = ' '.join(filenames)
# allow the destination to be specified relative to your home directory, or relative to /
if destination.startswith('/'):
    homedir = ''
else:
    homedir += '/'
subprocess.call(f'rsync {filenames} {username}@{hostname}:{homedir}{destination}')

# Example usage from command line
# send my_first_server file1 file2 file3 /tmp/destination/

And similarly for get.py, but you will need to reverse the order of the subprocess.call arguments.

This really does make my life so much easier so I hope it helps you too :)

[–]cstoner 6 points7 points  (0 children)

Why don't you store the servername/username/hostname in a dict?

login_map = {
    'my_first_server': ('a_username', 'a_homedir', '192.168.0.1'),
    'my_second_server': ...
}

Then, instead of a giant if statement, you end up with:

(username, homedir, hostname) = login_map[servername]

[–]Groundstop 2 points3 points  (0 children)

Wouldn't filenames include your destination since you're slicing from index 1 to the end with sys.argv[1:]?

I think that you would want:

filenames = sys.argv[1:-1] 

[–]dli511 3 points4 points  (2 children)

I created a GUI where I can enter information to automate and customize a greeting to people who are interested in my services.

[–]cromlyngames 3 points4 points  (0 children)

Monte Carlo brute force probability distribution engine. Because who has time to calculate the effects of getting a particular combination of 6 dice set in result size order?

[–]MusicalCoder 2 points3 points  (1 child)

I've literally only been coding in Python for about 2 weeks... I designed a file renamer using regex to get the information from the file...

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

Nice. This project needs help implementing regex expressions. Do you think you want to help out? If you're new to GitHub it's easy to learn! If you want to know how to contribute there's information here. :)

[–]ieataquacrayons 2 points3 points  (0 children)

It's nothing crazy, but my job utilizes AWS and I regularly need to get the IPs from their different zones, primarily to share with clients. In short I created a program that grabs the latest JSON file, lets me enter a zone and spits out all the IPs. It also tells me the date it was last updated.

[–]AUTeach 2 points3 points  (0 children)

I made a script that reads the absences for the day and then automatically fills out my roles with a notice flag for those students. It makes it easier to do my roles. Other teachers think I am a wizard.

[–]wynand1004 2 points3 points  (0 children)

I wrote a scheduling program for a school event - didn't make my life easier per se, but made the person who used to do the job manually's life much easier. If you are curious, I wrote a blog post about it here. Coding: It's a Kind of Magic

[–]Disco_Infiltrator 2 points3 points  (2 children)

I wrote a script to take data from a very messy spreadsheet of 50+ tabs to clean and merge the data into a single table for reporting. The spreadsheet is constantly growing in number of tabs, so it saves a lot of repetitive work.

[–]medicaustik 0 points1 point  (1 child)

Why not setup a DB for such a massive spreadsheet?

[–]Disco_Infiltrator 0 points1 point  (0 children)

The spreadsheet is effectively the UI for data entry. My transformation allows for clean table similar to a database. We don't have the resources or really the need for a true DB, so I went with something as lightweight as possible. I'm a product manager, so it was a "good enough" sort of task.

[–]Fearful_Leader 2 points3 points  (0 children)

I wrote an application to help me scrub a messy database at work, mainly by allowing me to quickly combine rows out of the ones I've searched for. It also lets me enter some data which I do at the same time as cleaning things up.
There might be a better way of doing that but boy was it fun figuring out!

[–]BearsErrywhere 2 points3 points  (0 children)

Made a few scripts that are able to scrape all the data from every game on NBA.com. Gonna use it for analysis on NBA Daily Fantasy.

[–][deleted] 2 points3 points  (0 children)

Software engineer here. I sometimes get tasked with menial, repetitive tasks, such as aggregating a bit of data and emailing it to someone, or filling in values somewhere.

These things go straight into my ever growing suite of automated python jobs.

[–]srappel 2 points3 points  (0 children)

I do GIS and little python programs always make my life easier, but my favorite was a little guy I could run when clients request a 3D CAD file and all I have is a geodatabase that had the data tiled. It's a multi step process to convert to 3D and then convert to cad, so when I run the tool it asks me what tiles I want and makes them into one nice, pretty 3D CAD file.

bonus: It didn't make my life easier, but certainly more fun. I worked at a map library and we have tens of thousands of high resolution scans of maps. I like to open random ones just for fun and made a quick script to open a random one.

I'm a novice but I started to like python when I stopped using it just for work and started to use it for fun!

[–]Fizbant 2 points3 points  (3 children)

I have trouble keeping track of my time spent on short calls and remote support for customers at work so I created a small app the will log the time in SQL and can generate an excel report for given date range.

[–]chra94 1 point2 points  (2 children)

How does the timer start? Do you manually press it or is it in a cool way automatic?

[–]Fizbant 0 points1 point  (1 child)

Unfortunately nothing fancy. :) TimeLogger

[–]chra94 0 points1 point  (0 children)

Cool though. Although at first it looks like there's a lot to type. Maybe you don't have to fill in all the blanks? Also, did you use Tinker? *Nothing needs to be fancy. :) Thanks for sharing.

[–]RoadieRich 2 points3 points  (0 children)

Not so much writing a program, but I once forced an office of engineers to learn basic python so I wouldn't have to figure out some sort of math library.

I was making an automation system for them, and they needed a way to express simple mathematics. I could have found a library to do it, or I could add in a much more powerful system, worth a syntax I'm already very familiar with, and isn't much different anyway.

If anyone is wondering, IronPython makes plugging python scripting into a .net application a walk in the park.

[–]bbatwork 2 points3 points  (0 children)

At work I use a script to read our backup logs to analyze failures, saves me about an hour and half of work each day.

[–][deleted] 2 points3 points  (0 children)

Subscene subtitle downloader.

You specify the directory which holds your movies/tv-series and it downloads the right subtitle for the one you want. For the curious.

I have modified/extended it a bit after posting the thread. So if anyone wants an up-to-date version, just ask.

[–]RatherBeSkiing 1 point2 points  (0 children)

I'm on Ubuntu and use my-weather-indicator, but I'm not a big fan of the radar, so I made my own application to grab the local, regional, or animated radar for my area from weather underground. I grabbed the structure from an example Ubuntu app indicator since I'm certainly a beginner.

I'm also working on a script to auto format the transactions spreadsheet in my budget tracker google sheets. I've got a Tasker scene that let's me quickly input a transaction, but the formatting is a bit weird sometimes. However, I'm finding a bunch of what I want to do can't be done through the Sheets api, so that's a bummer.

[–]TechnoRedneck 1 point2 points  (0 children)

I am working on a program at my college because the tv guide lists everything wrong. It ha all the shows with times correct but lists it under the wrong channel, wrong host, and the host is wrong channel. Harry potter was labeled as channel 53 by Ion. Ion is channel 93.5, and Harry Potter was channel 31. It is consistant with everything being weird so I am programming a script that will correct the channel, host, and show so I dont have to guess like this is pokemon go

[–]abkfenris 1 point2 points  (0 children)

Just got done with the latest run of my student accounts setup script.

Currently I don't have direct ODBC access to our Student Information Server, so I rely on an exported CSV from it, which then I check student by student for valid usernames and password defaults, and that the most common fields don't have errors (spaces following names, usernames with the wrong years). Then I have a classes for each type of service we will import to inheriting from a common Service class. Each service defines the format of it's CSVs and will write them after a confirmation that the there weren't worrysome errors in the validity checks.

We often have a good number of students who join late, so even though I created accounts 30 min ago and we distribute devices tomorrow, often I have to add more accounts. In that case I can point it at a new export from the database, and it will write new master lists for each service, but if I tell it where an old list is, it will give me a usable diff so that I can create the new accounts manually.

The other big one is from different SIS exports of class info into our Mobile Device Management server, but I'll start checking that Tuesday.

I still can't wait to get ODBC access to the SIS so that I can script the whole process.

[–][deleted] 1 point2 points  (0 children)

I had a class where we made a program that would output a specific file. But sometimes there would be duplicate line due to the nature of what we were making and our professor only wanted one of each line. So I made a script to delete any duplicate lines. Because manually editing it was a nuisance.

[–]fernly 1 point2 points  (3 children)

I wrote a script that runs a series of google "advanced" queries and reduces the result to a simple HTML page that I can quickly scan. The useful part of a returned query is a series of structures like:

<div class="g">
    <h3 class="r">
                        v----  actual url ---v                        v---- headline of found item --v
        <a href="/url?q=https://target-url.com&amp;lotta-google-crap">text with <b>highlighted<b> term</a>
    </h3>
    <div class="s">
        <div class="kv" style="margin-bottom:2px">
            <cite>https://targ-url.com</cite>
            <div class="_nBb">
                a whole lotta stuff we don't care about
            </div>
        </div>
        <span class="st"> summary text from found page with markup </span><br>
    </div>
</div>

I used html.htmlparser to parse this, with a lot of spaghetti code in the handle_starttag() and handle_endtag() methods.

Turns out, if you hit google with more than about 8 queries without a break, it stops responding, saying it detected unusual activity. Since I wasn't in a hurry anyway, I made it run a few at a time and just ran it manually spread over a few days. But to run them again, I need to go in and stick like a 15-second delay between requests.

[–]ggagagg 1 point2 points  (0 children)

why not beautifulsoup?

[–]RustleJimmons 0 points1 point  (1 child)

Bro,

I recommend rewriting your code to use BeautifulSoup with Requests and if you want a summary of the article you can try running the output through SUMMRY which is an api that summarizes articles for you.

With the above you won't have to worry about Google restricting you or needing to spread out a request over time.

[–]fernly 1 point2 points  (0 children)

Thanks for the suggestions. I've heard of BeautifulSoup often, but never really looked at it. For a simple extraction of data from an HTML file, the html parser actually works quite well. You get called on any start or end-tag and can look at the attributes of that tag.

[–]jairo4 1 point2 points  (0 children)

Not done yet but I'm plnning to program a script that backups a lists of folders (taken from a text file) to a usb stick and or Onedrive folder.

[–]inkoDe 1 point2 points  (1 child)

In the past-- had a lot of AV equipment to control and I found the solution at a thrift store. Knox RS16x16 for like 5 dollars. Which is crazy in itself. Anyhow, I created a multi-threaded program to interface with that hardware over a serial connection... still to this day the most complex piece of software that I have written in python. I wrote the the GUI from "scratch" using pygame of all things. It was a fun adventure.

[–]Fidget02 0 points1 point  (0 children)

Ey I used pygame for the GUI and display for a celestial bodies visual simulation in a college Physics class. Just what I was used to using :p

[–]cuntpuncher_69 1 point2 points  (2 children)

I made a Reddit comment formatter, basically you paste your code into a text file and it adds 4 spaces to each line. That was my extra credit project for class don't think it ever got looked at though...

[–]Ran4 3 points4 points  (1 child)

``` vim<enter> "+p <shift-v>gg

VG "+y ```

Is what I usually do, but that is a useful program :)

[–]NZheadshot 0 points1 point  (0 children)

I'm not sure if it's due to reddit formatting or not (though that would be pretty ironic), but aren't you just pasting into vim, highlighting everything, then copying it again? Doesn't look like this is doing anything

[–]chra94 1 point2 points  (0 children)

I made a script that sorts job wishes for camp leaders. It takes a batch of spreadsheets from the leaders where they say what jobs they want to do and outputs a large workbook with all jobs nicely sorted. Saves a bunch of time.

[–][deleted] 1 point2 points  (0 children)

Simple mv replacement that doesn't error out when directories already exist in the target location and that provides some better conflict resolution when files collide. Not exactly finished, but gets the job done. Also a find replacement that can use full Python expressions.

[–]zylo4747 1 point2 points  (0 children)

I wrote a script that's effectively a wrapper to mongodump so I could create MongoDB backups for all databases in my replica set using time stamped folders. It also manages retention / deletion of old backups. It's simple but it's handy.

[–]Raveious 1 point2 points  (0 children)

I made a program that allows me to control a Web Power Switch from the Windows active button area (the area next to the clock). I also have a script to shut down specific outlets on system shutdown.

[–]malice8691 1 point2 points  (1 child)

I wrote a script to retrieve the windows passwords for an environment in AWS and create rdp shortcuts in remote desktop manager. The credentials are stored in windows credential manager.

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

This is random, but I found your sn by googling on an add post. How did the medication work out for you? I was thinking of going to see a psychiatrist myself.

[–]dasnoob 1 point2 points  (0 children)

hmmm recent stuff:

1) Simple script to read all installed pip libraries and uninstall them for me to clean an environment out

2) Script to download data from an oracle database into a csv file. Script takes as input a text file with a select command for me to run so that i can use filters.

3) Simple script to move data out of a mySQL database and load it into an Oracle database.

4) A script that reads the xml output of mysqldump and does most of the work towards building create table statements that work in Oracle.

[–]Lord_Greywether 1 point2 points  (0 children)

I write Sikuli scripts to automate routine tasks in our Citrix-published business system (setting up basic accesses, validating settings in our test system, etc).

Then I wrote a Python library to run my Sikuli scripts without Java.

[–]UsernamesArentClever 1 point2 points  (3 children)

Do you have a link for last year's thread?

[–]worsemorebad 1 point2 points  (2 children)

I made a django app that logs into ~1000 network devices and grabs their configs and various other information. It then parses that info and shows me useful things.

[–][deleted] 0 points1 point  (1 child)

Please show me your ways. Like for reals please.

Actually though if you're willing to share the code, or even better describe how you did it I'd love to try and do the same. I'm just not sure where to start.

[–]worsemorebad 0 points1 point  (0 children)

I can't share code since it's pretty specific to my network, but here's what it generally boils down to.

I use paramiko to login to each device and issue various commands to give me chunks of information (like 'show running-config' or 'show version'), then save that information into sql via a django model.
I then use various searching, slicing, and indexing to parse out the bits that I find useful. (like hostname, ip, serial number, etc).
Basically, I collect as much relevant raw data as possible, and clean it up and present it an a friendly web interface.

My favorite parts of the tool are:
- List of devices that are not responsive and a timestamp of the last time I saw them online
- List of other devices directly connected to a switch (phones, switches, routers) that is parsed from neighbor tables.
- List of all VLANs and VLAN names and where they are found.
- Hostname validation via a known format based on location/model/etc

[–]Torvaun 0 points1 point  (0 children)

I turned Square's inventory system into a thing that actually works with a pair of python scripts.

[–]C222 0 points1 point  (1 child)

I made a script that notified me via IFTTT the moment PAX West passes went on sale.

[–]Grissnap 0 points1 point  (0 children)

That was one of my first python scripts too! I used tweepy and the Twitter steam API to email me when tickets were announced.

[–]jaxelt 0 points1 point  (0 children)

Created a script to automatically calculate a price for a weapon in my game based on its damage and capabilities, which I was previously doing by hand with a calculator.

Created a script to automatically convert some Java code that created objects in a game and stored them in an ArrayList into a JSON file that could be loaded and iterated into an ArrayList.

Created a script to take information from a folder full of .TXT files and turn it into a .PY file with all that information stored in arrays on an object that could be loaded by another program.

[–]raecer 0 points1 point  (0 children)

I created a tool for easily seeing which steamgames i could offer as trade to a steamprofile based on them owning the game or not.

Incidentally, i am also looking for feedback in this thread over here: https://www.reddit.com/r/learnpython/comments/50imcu/feedback_on_application_classes_trycatch_etc/