Here is a generator that basically goes forever in a circular list from 1 to 12 def get_next_month(month): i_month = month while True: if i_month == 12: i_month = 1 else: i_month = i_month+1 yield i_month Here is how to use it. def month_current_and_next(month, count = 1 ): if month == 0: time_t = datetime.now() current_month = time_t.month else: […]
Python – generator example
Python tip – convert to “raw” string
This is useful for Windows pathnames and other situations where you don’t need string interpretation. Such as handling text as blob. raw_s = r'{}’.format(s)
Monitoring io performance with IOTOP
IOTOP: Shows real-time stats for disk. I attached a SC1 device and wanted to see how it ran on AWS root@jaws /]# yum install iotop Loaded plugins: priorities, update-motd, upgrade-helper amzn-main | 2.1 kB 00:00 amzn-updates | 3.8 kB 00:00 Resolving Dependencies –> Running transaction check —> Package iotop.noarch 0:0.3.2-7.6.amzn1 will be installed –> Finished Dependency Resolution Dependencies Resolved ================================================================================ […]
Graviton free trial extended until end of the year
tg4.micro trial continues. It has a lot of promise, but things need to come together. Free Trial: All new and existing AWS customers can try the t4g.micro instances free until December 31, 2021. During the free-trial period, customers who run a t4g.micro instance will automatically get 750 hours per month deducted from their monthly bill. Refer to the FAQ for additional […]
Fuzzy matching
Some interesting links on Fuzzy matching: https://en.wikipedia.org/wiki/Levenshtein_distance Python library that implements Levenshtein. https://github.com/seatgeek/fuzzywuzzy
Jupyter Notebook Markdown tutorial
Nice tutorial on markdown text capabilities. Brynmawr tutorial
Python – getting seconds since midnight
import datetime now = datetime.datetime.now() midnight = now.replace(hour=0, minute=0, second=0, microsecond=0) seconds = (now – midnight).seconds Can be made into an easy function. And conversion to minutes and hours easy.
High cpu use Google cloud
Run a top command user@ iowa-1$ top top – 14:18:43 up 160 days, 12:15, 1 user, load average: 0.25, 0.23, 0.14 Tasks: 68 total, 1 running, 67 sleeping, 0 stopped, 0 zombie %Cpu(s): 3.5 us, 4.6 sy, 0.0 ni, 91.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st MiB Mem : 583.3 total, 86.6 free, 191.5 used, 305.2 buff/cache […]
Add versions to css and javascript.
If you change css or js files on a live webserver, change the versions. Symptoms: css not taking effect or when you look at the css in the browser the changes are not there. Work-around: Do a <ctrl> – <F5> or a <ctrl>-<shift> – <F5> to force a hard refresh on browser https://css-tricks.com/strategies-for-cache-busting-css/
List of mime types
This is for type= tag in htmls and other things https://www.iana.org/assignments/media-types/media-types.xhtml