Installing Chocolatey Package Manager

Chocolatey

What is Chocolatey?

Chocolatey is a package manager for Windows 7+.  It allows you to install applications with simple command-line commands. For example:

choco install googlechrome

or

choco install skype

How do I install it?

  1. First, open an administrative Windows PowerShell prompt by doing the following:
    1. Copy the string “powershell start-process powershell -verb runas” to your clipboard.
    2. Press Windows+R
    3. Press Ctrl+V
    4. Press Enter.
  2. Now, copy the entire following block of text:
    Set-ExecutionPolicy Unrestricted
    iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

    Paste into the PowerShell prompt, then press enter.

(Note: it will prompt your permission to proceed. Type Y and press enter.)

How do I use it?

First, visit the Chocolatey Gallery to see the complete list of packages available, and to search for packages.

To install a package, simply type, as I’ve already shown above, something like:

choco install googlechrome
Advertisements

Proving equations with Sage

Recently, I was doing proof-by-induction exercises for a course I was taking.  As a practice problem, I found myself with the following equation:

pbieq.png

So…my next step was to determine whether this equation is true or false. This is easy enough: I could use use basic algebra to expand/factor both sides until they match.

The thing is, I’m lazy.  I’d rather have a program tell me whether or not an equation is true.

Enter Sage—an open-source math library that has a python-based command-line interface. To install it on Ubuntu Linux, I simply ran:

sudo apt install sage

Once installed, you I was able to run sage on the command line; e.g.,

~$ sage
┌─────────────────────────────────────────────────────────────┐
│ SageMath version 7.2, Release Date: 2016-05-15              │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help.                                     │
└─────────────────────────────────────────────────────────────┘
sage:

I entered the following, to test my equation:

k=var('k')
bool( (k/2)*(3+5*k)+(5*(k+1)-1) == ((k+1)/2)*(3+5*(k+1)) )

The result was:

True

 

USBank’s Password Policy

Recently, I went to change my USBank password.  I continue to be shocked every time it tells me it does not allow spaces:

cyp.png“Please create a new password that’s between 8 and 24 characters with no spaces. Your password should include both letters and numbers and may also include special characters (such as %, $, &).”

This is just silly—there’s no absolutely no reason they should prevent spaces.  For me, this shows a lack of care; a lack of finesse; a lack robustness at their gates of security.

This is about more than just spaces, too.  Their password change process is simply not modern.  It’s so 2000’s.  My gaming account on Steam has a more robust password change process.  I can list five things Steam does better than USBank regarding password security:

  1. They allow any characters in a password.
  2. They show a password-strength meter when typing a password.
  3. They authenticate the user via an email confirmation code before changing password.
  4. They send you an email notification when someone tries to sign in from a new device or computer.
  5. They allow multi-factor authentication.

I’ve been annoyed at USBank for this since I first got an account there, probably around 2005.  But, it’s 2017. C’mon.

CsvGatling: a C# CSV parser


CsvGatling


CsvGatling is a fast, scalable CSV parser with a simple C# interface.  The source code is hosted on GitHub, and I licensed it public domain.

Minimal Example


Imagine we have this CSV file:

Name,FavoriteColor,BirthDate
John,Red,11/2/1980
Ted,Green,4/3/1989
Chris,Blue,11/10/2000

We’ll create a class to map each row to:

public class Person
{
    public DateTime BirthDate { get; set; }
    public string Name { get; set; }
    public string FavoriteColor { get; set; }
}

Then, to read the file:

using System;
using System.IO;
using CsvGatling;

using (FileStream fileStream = new FileStream(@"C:\Path\To\CSV\File", FileMode.Open))
{
    ICsvReader csvReader = new CsvReader(fileStream);
    foreach (Person person in csvReader.ReadAll())
    {
        Console.WriteLine("{0} was born on {1:M/d/yyyy}, and his favorite color is {2}",
            person.Name,
            person.BirthDate,
            person.FavoriteColor);

    }
 }

The output will be:

John was born on 11/2/1980, and his favorite color is Red
Ted was born on 4/3/1989, and his favorite color is Green
Chris was born on 11/10/1900, and his favorite color is Blue

Design


CsvGatling…

…is simple. As shown in the example above, its very simple interface makes it extremely easy to use.

…is streaming. It will not try to read the entire file into memory; it will only read rows into memory as they are being read.

…is scalable. There are no size limits, and the library can easily read CSV files of any number of rows and any number of columns.

…is fast. It uses System.Reflection to map column names to properties with the same name, and usesSystem.Reflection.Emit to dynamically generate code to avoid the need to use Reflection for each row.

…follows the RFC 4180 standard, with a few caveats. By default, fields are comma separated, lines are new line separated, quotes use double-quotes, and quotes are escaped by having two neighboring quotes, just as the standard says. (The caveats are: (1) CsvGatling will work for both UNIX (\n) and Windows (\r\n) line endings. (2) Files must have a header. (3) Users can choose to use different column delimiter and quote characters with the appropriate method overloads.)