Sunday, May 16, 2021

Calculating total price in a text list of items

 So I have this list of stuff I want to buy:

> Latest total, correct?

> laser guns 100, magnetic wall calendar 150, 2 trays 20, twin sheets 40, blue twin sheets 30, boots 50, 3 pot set 200, electric kettle 200, toaster 50, blue Pyrex 100, set of 3 food storage containers 75, salad spinner 40, PC Batter bowl with lid 100, white/flower serving dish 30, cast iron skillet 80, microwave 400, pizza pans 50, splatter guard 20, muffin pan 40, file box 100, cooling rack 40, blue table cloth 50, basting brush 20, tongs 10, meat scissors 40, ice cream scoop 30, potato masher 30, pastry blender 20, meat tenderizer 10, 2 large knives 80 lei, spatula 10, Zester 10, meat thermometer 10, Black File folder 10, black knife/sharpener 20, all metal hangers 100, 3 kitchen items 110, children’s hangers 20, total - 2585.

How to verify without manually adding? Using VS code and Python:


Press "Replace all", and you get: "100,150,20,40,30,50,200,200,50,100,75,40,100,30,80,400,50,20,40,100,40,50,20,10,40,30,30,20,10,10,10,10,10,20,100,110,20,".

Then

$ python

>>> sum([100,150,20,40,30,50,200,200,50,100,75,40,100,30,80,400,50,20,40,100,40,50,20,10,40,30,30,20,10,10,10,10,10,20,100,110,20,])

2415

>>>

Wednesday, April 28, 2021

Tweaking color scheme in PyCharm

I've decided to document my changes to the color scheme in PyCharm (macOS), which in my view improve the working mode. 

Choose the color scheme 

Preferences -> Editor -> Color Scheme: Choose Darcula 

Tweak the color scheme 

By default Darcula color scheme has operators in white color -- the same color as "Identifier" color. So when I have in code something like `var1 + var2` they are the same color, which reduces understanding of the code, IMO. Preferences -> Editor -> Color Scheme -> Language Defaults: in the tree find "Braces and Operators" and for all of them set foreground color the same as defined for "Comma" (orange in my case). 

Remove warning marks from scrollbar 

Preferences -> Editor -> Color Scheme -> General -> Errors and Warnings: "Warning",  "Weak Warning", "TODO Defaults" and uncheck "Error stripe mark". I do this to not have in the editor scroll bar only marks for syntax and other critical errors. The lower errors I'll see in the code itself. I am using the scroll bar marks to find my bookmarks and critical errors. 

So here is the result:

Friday, January 31, 2020

Why Good Developers Write Bad Tests


Many skilled developers write beautiful code but horrendous tests. Worse, they're oblivious to the problem because their code seems to follow best practices. Come to this talk to find out why refactoring degrades readability, magic numbers are your friends, and DRY means DO repeat yourself.

Monday, July 30, 2018

Effective Estimation (or: How not to Lie)

YOW! 2016 Robert C. Martin - Effective Estimation (or: How not to Lie)
Everything you ever wanted to know about how to estimate software tasks, and how to communicate those estimates to the business. We’ll discuss honesty, accuracy, and precision; and the best ways to satisfy all three.
Uncle Bob has been a programmer since 1970. He served as the Master Craftsman at 8th Light inc, is co-founder of the on-line video training company: cleancoders.com, and founder of Uncle Bob Consulting LLC. He is an acclaimed speaker at conferences worldwide, and the author of many books including: The Clean Coder, Clean Code, Agile Software Development: Principles, Patterns, and Practices, and UML for Java Programmers. He is a prolific writer and has published hundreds of articles, papers, and blogs. He served as the Editor-in-chief of the C++ Report, and as the first chairman of the Agile Alliance. He is the creator of the acclaimed Clean Code educational video series at cleancoders.com.

Tuesday, January 30, 2018

Pycon UK 2016: Avoiding the "left pad" problem: How to secure your pip install process

Aaron Bassett
When Azer Koçulu pulled 11 lines of code from npm he not only broke thousands of dependent packages but also prevented developers all over the world from deploying their code. This talk will show how you can harden your pip install process, ensure that packages have not been tampered with, protect against MITM attacks and even how to keep deploying if a package is deleted or if PyPI goes offline.

Friday, October 13, 2017

What's new in Python 3.7

There are many things in the Python 3.7 release notes but I like this:

PEP 553 describes a new built-in called breakpoint() which makes it easy and consistent to enter the Python debugger. Built-in breakpoint() calls sys.breakpointhook(). By default, this latter imports pdb and then calls pdb.set_trace(), but by binding sys.breakpointhook() to the function of your choosing, breakpoint() can enter any debugger. Or, the environment variable PYTHONBREAKPOINT can be set to the callable of your debugger of choice. Set PYTHONBREAKPOINT=0 to completely disable built-in breakpoint().

Thursday, August 10, 2017