Skip to content

Instantly share code, notes, and snippets.

View AndyDeNike's full-sized avatar
💭
Set your status

AndyDeNike

💭
Set your status
View GitHub Profile

Lambda meets filter

Essentially a lambda is just an anonomyous function; no 'def' declaration is necessary, only the 'lambda' keyword. Functionally a lambda is just a function! Consider using lamdba to define smaller, non complex functions.

lambda x: x

functionally the same as

Date string to datetime object

You've already turned a datetime object into a formatted string with 'strftime' but now, in order to transform a date string into a datetime object, you will need to use 'strptime' !

datetime.strptime() takes two parameters:

First, the string that is written in a datetime format (example 'May 12 2001 2:22PM')

Seconds since the beginning of time

What if there was a way to find out how many seconds have passed since the very beginning of existence? Many have said "Nobody knows that" but they aren't taking Unix time into consideration.

Known as the 'epoch', the Unix operating system was created by the gods of Unix at a single datetime point of 00:00:00 Thursday, 1 January 1970 (UTC).

How can we capture this origin point of all Unixistence? We can use the

Calculate side of 90 degree triangle

Assuming we have the length of the right angled triangle's hypotenuse AND an angle of its other corners (not the 90 degree), write an equation that will give us the distance of the opposing side of the given angle.

Image of Triangle

The equation that represents this scenerio is: