Skip to content

Tag: programming

conditional past, present, future in spreadsheets/Excel

=IF(B2=TODAY(),"Past",IF(B2<TODAY(),"Today",TEXT(B2,"ddd")))
  • Given a column B that contains dates in a sequential order.
  • Shows a “Today” when it’s today.
  • Shows a “Past” when is past.
  • Shows an abbreviated name of the day of the week.

Here is an example using emojis instead of past/today:

Ruby super

class A
   def foo 
      [1, 2, 3]
   end 
end

class B < A 
   def foo 
      super.map{ |n| n * 2 } 
   end 
end

puts A.new.foo.to_s
puts B.new.foo.to_s

Output

[1, 2, 3]
[2, 4, 6]

Python: Getting page title

# Get the HTML page content
from urllib import request
html = request.urlopen("https://silveiraneto.net").read()

# Get the title tag
from bs4 import BeautifulSoup
title = BeautifulSoup(html, 'html.parser').find('title')

print(title.string)

This uses the XML/HTML library BeautifulSoup . This could also be done using regex but playing with HTML and regex is usually a bad idea.