Python Learning: Automate Boring Stuff with Python | Chapter 8 : My Solution to Practice Project: Deleting Unneeded Files

Personally, one of the simplest projects yet This code (when properly indented) helps to list out all files with a size greater than the given limit.   # Usage python big.py limit in MB import sys import os if len(sys.argv) >= 2: limit = sys.argv[1] if len(sys.argv) == 3: source = sys.argv[2] else: source = […]

Python Learning: Automate Boring Stuff with Python | Chapter 8 : My Solution to Practice Project: Selective Copy

As usual… super simple automation.. I know it is quite trivial, but the fact that with a few lines of code I could re-organize my files based on their extensions makes coding really fun even outside of work. Code # selective copy # walks through a folder tree and searches for files with a certain […]

Python Learning: Automate Boring Stuff with Python | Chapter 8 : My Solution to Project: Backing Up a Folder into a Zip File

Just my solution to the project I found the solution to the project provided in the book really good, but it zipped the entire folder structure in the absolute path. Something I am not pleased with. By adding the filepath base name to the zipfile.Zipfile.write() function, after the absolute file path (of the file to […]

Python Learning: Automate Boring Stuff with Python | Making a directory and moving files into it

With this script we can make a new directory and move files with a given ending into the directory. This was not a task in the book, but just something I thought of solving. Quite interesting to know what you could do with string operations like “startWith” and “endWith”. # creates new directory and moves […]

Python Learning: Automate Boring Stuff with Python | Chapter 8 : My Solution to Project Regex Search

Searching through a list of text files in a given directory … I personally found this enjoyable. It was easier to solve compared to last problem. What I can say at this stage is, learn how to search to documentation and google! It helps… heheh.. oh yea, leave your suggestions in the comment box. see […]

Python Learning: Automate Boring Stuff with Python | Chapter 8 : My Solution to Project Madlib

Creating MadLib:   It was quite a task to solve this problem but worth it. I learned how to retrieve command line arguments using sys module, regex to match and search for the keyword in a given string, and os to create new files and open files.  I think a step further would be to […]

Python Learning: Automate Boring Stuff with Python | Chapter 8 : My Solution to Project Multiclipboard

# mcb.pyw : Saves and loads pieces of text to the clipboard # Usage: py.exe mcb.pyw save <keyword> – Saves clipboard to keyword # py.exe mcb.pyw <keyword> – Loads keyword to clipboard # py.exe mcb.pyw list – Loads all keywords to clipboard # py.exe mcb.pyw read <path text file> <keyword> import shelve import pyperclip import […]

Python Learning: Automate Boring Stuff with Python | Solution to Part II Chapter 7 Practice Project II

import re #first argument – string to be stripped #second argument – char or default ” ” def customStrip(string: str, stripChar: str=”\s”)->str: ”’ Removes specified character from the beginning and end of a given string arguments: string: str stripChar: str returns: string ”’ if stripChar == “” or stripChar == ” “: stripChar = “\s” […]

What I learned today | Functional Js | Higher Order Functions – Chapter 4

If you came all the way from part 1, you should get the book: Functional JavaScript In the last post, we learned about Closures and Scopes. Today, we are addressing Higher Order Functions – Let’s do this! Higher Order Function A first-class function takes a function as an argument returns a function as a result […]

What I learned today | Functional Javascript: Variables Scope and Closures

Remember the Book: Functional JavaScript   So chapter 3 right?…hm Scopes From my understanding, where a variable lives, while the extent of a scope means how long a variable holds a value. Global Scope This has the longest lifespan when you declare a variable without the var, you are defining a global variable (accessible to […]