Bash on WSL is great.
But if you want a little extra from your terminal you can install zsh and oh-my-zsh pretty easily.
- Ubuntu WSL
| # Constant declarations. | |
| min_occ = 1 | |
| max_occ = 4 | |
| min_adl = 1 | |
| max_adl = 4 | |
| min_chl = 0 | |
| max_chl = 2 | |
| results = [] | |
| adult = min_adl |
| import unittest | |
| from datetime import datetime, timedelta | |
| from unittest.mock import patch | |
| # Mocking describes replacing objects or functions | |
| # in a piece of logic with another. A prime example | |
| # is when we want to test a function returning a result | |
| # based on datetime.now(). As it is always changing, it's |
We can use a simple command to remove files under x size
> Get-ChildItem . -Filter *.xml -recurse -file | ? {$_.length -lt 105} | % {Remove-Item $_.fullname}Let's break this down at the pipes and look at each section;
Get-ChildItem . -Filter *.xml -recurse -file| class Rounding | |
| { | |
| static void Main(String[] args) | |
| { | |
| // Round up = 1 | |
| Math.Ceiling(0.5); | |
| // Round down = 0 | |
| Math.Floor(0.5); | |
| var | |
| FormatSettings: TFormatSettings; | |
| DateString: String; | |
| DateTime: TDateTime; | |
| begin | |
| FormatSettings := TFormatSettings.Create; | |
| with FormatSettings do | |
| begin | |
| DateSeparator := '-'; |
| """ | |
| iterparse(source, events=None, parser=None) | |
| Incrementally parse XML document into ElementTree. | |
| This class also reports what's going on to the user based on the | |
| *events* it is initialized with. The supported events are the strings | |
| "start", "end", "start-ns" and "end-ns" (the "ns" events are used to get | |
| detailed namespace information). If *events* is omitted, only | |
| "end" events are reported. |
| # guardian_reader.py | |
| # Excellent package for doing HTTP Post and Gets etc. | |
| import requests | |
| # Out of the box XML parsing. | |
| from xml.etree import ElementTree | |
| URL = 'https://www.theguardian.com/society/deafness/rss' | |
| def version_is_new(a, b): | |
| """Returns True if version `a` is newer than `b` | |
| Args: | |
| a: String version number to compare | |
| b: String version number to compare against | |
| Returns: | |
| True if `a` is newer than `b` | |
| """ |