Skip to main content

#100DaysOfCode, Day 015 – Quick and Dirty Web Page Download

Finally got the program done!
I wanted to write a program that would just get the latest comic from turnoff.us and save the picture to a file.

In the course of writing this little program,

  • I learnt about the basics of context handlers
  • I learnt about the os module in Python
  • I learnt how to scrape a web page using requests, beautiful soup and feedparser. (I was going to originally scrape the web page, but then realised that processing the rss feed would be more efficient. I think it’ll also help me extend/improve the program better, later.
  • It helped me practice, slicing and dicing Python lists and dictionaries and getting data out of them.
  • I learnt how to write and save files to disk.

This was really fun to do.
I see a million ways to take this dinky, little program forward. It could do the whole site for example or download only after comparing the state of the rss feed and fetching new entries etc. It has no error handling at all currently, and I prefer to have very safe, very conservative programs as a user. So lots of work to do. I leave all this for a later date though, while I now forge ahead with my #100DaysOfCode journey.
Getting back to the challenges of the course itself, tomorrow onwards.


#100DaysOfCode, Day 014 – Classes, List Comprehensions and Generators

Did a video session again today, since I came back late from the doc.

Watched videos about building a small d&d game, using classes.
This was fun :)
Working on the challenge will be exciting.

And then some more on list comprehensions and generators.
I had one aha, about tools as I watched this.
The instructor used a regular expression to process a list and that little line, cut down his code by lots.
That made me realise that programming is simply picking up the right tool for the job, and that there are a plethora, to do the work you need to do. One is not necessarily better than the other, just that some are better suited to the job at hand, than others.
Revised how list comprehensions and generators work.
And like a dork, I just realised that the operative thing is comprehension. You write in a comprehensive way to build some sort of collection. A list comprehension to write lists, a dictionary comprehension to build a dictionary, a generator comprehension to … well, you get the idea :)

This is all I got for today.
Will work more tomorrow.

#100DaysOfCode, Day 013 – Test code using Pytest

Watched the video on the upcoming challenge to learn testing code.
Sounds challenging.
There are classes and decorators, which I have not worked with, but just read about.

Will see how it goes.
The idea of test driven development though, seems right up my alley.

#100DaysOfCode, Day 012 – Data Structures Video Refresher

Extremely tight and busy day today.
But still made the time to watch the videos for the next challenge in the course.
As a matter of fact, I think this is what I should do.
If I am in office, I ought to watch videos.
And spend the time at home when I can coding.

What videos?
The next little project they have involves data structure basics.
So today’s videos took me through lists and tuples and dictionaries.
And with this, I call it a day.

How to Stop Checking Your (My) Phone

As I battle my physical demons, the newsletter will probably be on this slightly off cadence as I struggle mightily throughout the week, thinking about what to write, failing and then at the last minute panicking and sharing a short snippet of something I love and enjoy.

LMP

I hope you do too :)

So where was I? Oh yea, my favourite personal development, web researcher, Mr. Barker has this to share on what the issue is with our minds and how we can all gain some perspective and a bit more happiness by not checking our phones ever so often.

From How To Stop Checking Your Phone: 4 Secrets From Research,

We’re not looking at the problem correctly. For starters:

You do not have a short attention span.
We have a “mind control” problem. But it’s not other people’s ability to control your mind. It’s your own.
We spend so much time trying to get others attention yet the true determinant of our happiness is where we direct our own.
So what do we do? Throw our phones in a wood chipper?

Well, I wouldn’t :) So what do we do?
We gain Attentional Control.
By strengthening the part of our brains called the Prefrontal Cortex (hereinafter referred to as the PFC), our thinking brain against the onslaughts of our lizard brain.

Here’s his 4 step plan in a nutshell.

1. Get your sleep. Get your exercise. Be healthy.

No sleep. PFC weak. That simple.
Even one round of exercise will improve your PFC strength.

2. Control your context.

Basically, what’s around you?
How is it that the phone slips into your hand and your thumbs go scrolling without you even realising it?
For me, I am a tech news junkie.
So if I am in a queue, or on the potty, or going to bed, I read!

And to fix that, I now rely on a simple trick I learnt in Atomic Habits.
Make any behaviour you want to encourage easier to do, and any behaviour you want to discourage harder to do.
So now, the news apps are not easily accessible, twitter is no longer installed, there are no notifications, and I have to type a complicated password to unlock the phone.
I am pleased to report, that while I am not completely cured, my consumption has dropped significantly.

3. Mindfulness

Well, this is my good habit!
Apparently it’s a good habit everyone should have.
Because, it is a superstrengthener of your PFC!
I even wrote a whole blog post about it.
Need I say more?

Well, I think Eric’s being a little sneaky here. When I look up, I see changes to mind, body and soul.
So in an even smaller nutshell, what he actually aims at is

4. Be the change, you want to see in yourself!

Once again, this is an idea I read in Atomic Habits.
The best way to sustain and build a habit?
By deciding that this is what I am like.
I hate exercise and physio, but I do it.
Why? Because I am a man with a broken back, who has learnt his lesson and wants to be healthy and pain free, and who exercises in order to stay that way.
I don’t stress about smoking.
Why? Because I am not a person who wants to ruin his life by being a smoker.
Vegetarians don’t stress about eating meat.
Why? Because they just don’t eat meat.

I decide, who I want to be :)
Like the old bon mot goes, It’s simple, not easy.
And it’s worth it.



P.S. Subscribe to my mailing list!
P.P.S. Feed my insatiable reading habit.