Tuesday, June 08, 2021

Not Gerrymandering Redwood City? How could we tell?

Until the 2018 election, elections for City Council seats were city-wide. In 2019, in response to a California Voting Rights Act lawsuit, the city began a process of partitioning voters into seven districts for the first by-district City Council election, held in 2020.

A redistricting process, based on the results of the 2020 census, will begin soon, and must be completed in time for the next City Council election in 2022. But what's a fair way to partition the city into districts? What outcome are we looking for, and what districting plan is likely to move us toward the desired outcome?

I am not a lawyer, but my vague understanding of the lawsuit is that when we have only at-large elections, certain non-white ethnic groups tend to be under-represented in elective office. This makes me think we ought to aim for a situation where the number of districts where a given ethnic group has a plurality of voters should mirror that group's proportion of the city's population.

Let's imagine a city where population breaks down by ethnicity like this:

  population percentage
White (non-Hispanic/Latino) 33,801 44.0%
Hispanic/Latino 29,810 38.8%
Asian 8,063 10.5%
Black/African American 1,655 2.2%
Native Hawaiian/Pacific Islander 732 1.0%
American Indian/Alaskan Native 152 0.2%
Two or More Races 2,311 3.0%
Some Other Race Alone 291 0.4%
Total: 76,815 100%

(source: https://www.redwoodcity.org/about-the-city/demographics/race )

What kind of districting scheme do we want to see? First, let me describe a partitioning that I would not like:

  • District 1:
    44% non-Hispanic/Latino white; 39% Hispanic/Latino; 11% Asian; 6% mixed/other;
  • District 2:
    44% non-Hispanic/Latino white; 39% Hispanic/Latino; 11% Asian; 6% mixed/other;
  • District 3,4,5,6,7:
    44% non-Hispanic/Latino white; 39% Hispanic/Latino; 11% Asian; 6% mixed/other;
How would such a partitioning scheme remedy the under-representation of the Hispanic/Latino or Asian demographic in elective office? I don't see how it would, either.

Since 1/7 comes to about 14%, how many of the 7 City Council districts would ideally have a plurality (if not a majority) of non-Hispanic/Latino white people? Of Hispanic/Latino folks? Of Asians? I would suggest that what we should aim for in districts is:

  • Three districts where the plurality of residents are non-Hispanic/Latino white;
  • Two or three districts where the plurality of residents are Hispanic/Latino;
  • One district where the plurality of residents are Asian
  • Maybe a district where the plurality of residents are mixed or other? Maybe.
Does this make any kind of sense as something to aim at? If not, why not?

Sunday, April 25, 2021

How many pages per character? (not a typo)

NOTE: if the tables below look smooshed, try clicking on the title above ("How many pages...")

Suppose you're writing a novel, or some other large-ish prose, and you want to balance the number of pages that your main characters or points-of-view (etc.) get. Or you just want to see how many pages each character (etc.) gets. If your magnum opus were a half-dozen pages or so, you could print it out and mark it up with colored highlighters or something, but if it's several hundreds of pages, with several dozen chapters, you might want to make a table.
action#pages
Adam adapts2
Emily eats7
Harry harrumphs1
Kayla kicks8
Emily investigates2
Harry gets a haircut8
That's all well and good, but if the table has a hundred (or hundreds) of rows, how do you figure out the distribution of pages among these characters? You could split the #pages column into multiple columns—one for each of your characters, like this:
actionAdamEmilyHarryKayla
Adam adapts2   
Emily eats 7  
Harry harrumphs  1 
Kayla kicks   8
Emily investigates 2  
Harry gets a haircut  8 
Then you can tell LibreOffice Calc or Mi¢ro$oft Excel™ to add up each column, and you can compare the column totals, like this maybe
actionAdamEmilyHarryKayla
Adam adapts2   
Emily eats 7  
Harry harrumphs  1 
Kayla kicks   8
Emily investigates 2  
Harry gets a haircut  8 
totals2998
But wait; this replaces one problem with another. What if the next scene/whatever you want to add is about Adam running into some issue: 5 pages, but you inadvertently add his #pages to the wrong column?
actionAdamEmilyHarryKayla
Adam adapts2   
Emily eats 7  
Harry harrumphs  1 
Kayla kicks   8
Emily investigates 2  
Harry gets a haircut  8 
Adam breaks a leg 5  
totals214←oops98
Here's an idea: this spreadsheet is on a computer, right? Aren't computers good at things like putting a number into a particular column, depending on the contents of another spreadsheet cell?

After taking way too long to figure this out, I thought I'd share with you what I did: I created a spreadsheet that looks like the first figure above, where we populate the #pages column. Then, consulting multiple web-search results, constructed formulas to copy the numbers in the #pages column into the appropriate cells in the "Adam", "Emily", etc. columns, depending on the contents of the action column. In the following table, the numbers under Adam, Emily, etc., are all computed by the spreadsheet:

action#pagesAdamEmilyHarryKayla
Adam adapts22   
Emily eats7 7  
Harry harrumphs1  1 
Kayla kicks8   8
Emily investigates2 2  
Harry gets a haircut8  8 
totals282998
  total→28 
As a bonus, we can add up the "Adam", "Emily", etc., pages; if the sum of all those columns matches the sum of the #pages column, that suggests that maybe each of those #pages numbers matched exactly one of "Adam", "Emily", etc.; we didn't miss any and we didn't double-count any. (We could miss by mis-spelling someone's name, and we could double-count by inadvertently including someone's name in the middle of a word. "Kayla reviews Madame Bovary" for example could match both "Adam" and "Kayla"; or if you wrote "Emily and Adam play squash" as one of the actions.) The spreadsheet uses a case-insensitive search to match the character names. There is probably an easy way to make that case-sensitive, but I'll leave that as an exercise for the reader.

Here's how you can use it.

  1. Download the libreoffice/openoffice file or the Excel™ file
  2. Replace "Adam", "Emily", etc., by your novel's (principal?) characters' names. If you have more than four characters:
    1. Put additional names to the right of Kayla in row 1
    2. Select C2–F2 and extend rightward to G2, H2, etc. to accommodate your additional characters
    3. Select B8–F8 and extend rightward to G8, H8, etc. to accommodate your additional characters
  3. Delete rows 3–6 (leave "Harry gets a haircut" as a placeholder; you'll see why shortly)
  4. Insert a dozen or a hundred rows before the "Harry gets a haircut" placeholder row, and populate columns C3–H103 (or however far to the right) by extending C2–H2 (or however…) downward to cover the new rows.
  5. As you insert action cells (start by replacing "Adam adapts") and fill in the corresponding value in the #pages column, the totals in the totals row should automagically update, because that row has cells that SUM everything from row B ("Adam adapts") up to and including the "Harry gets a haircut" row.
    [If I had planned further ahead, I might have called that row "leave empty for expansion" or something]
  6. To make the error-checking thing work for your expanded spreadsheet, ensure that the cell to the right of "total→" is the sum of the previous row's columns B–H (or however…)

Sunday, December 06, 2020

A lucky hdd recovery adventure

In all my years of home computing, I never had a catastrophic hard drive failure. Saturday's excitement felt like one, with I/O errors on the journal.

The usual graphical display on my computer was replaced by large white typewriter-style characters on a dark background, dire warnings about I/O errors, nonexistent device on remount, and other words I don't recall. I found a USB drive that still had knoppix 8.6, and booted. Diagnostics (CPU, memory) found no problems so I tried "e2fsck -y" on the failed partitions (both / and /home, which made me think "electronics" rather than "bad spot on the disk"). That ended with "Filesystem still contains errors!"

I tried to remove the journal with tune2fs, which insisted on first trying to replay the journal, that's right, the very journal I wanted to ignore/remove. After a few hours of futility, I had an idea. Since there were I/O errors on the disk drive, but all were happening at rather high block numbers (with at least 9 digits if I recall correctly), I thought, what if I just did a block-for-block copy onto a new drive?

Off to the store for a 1TB internal SSD with SATA connectors: about $100—a dime per gigabyte! This is an amazing time we live in. "fdisk -l" gave me the bad drive's layout; I partitioned the new drive with the same-size partitions... I think the new drive is slightly larger, but who cares? I copied the filesystem partitions over, and was pleasantly surprised to note that the filesystem uuids matched. (D'oh!) The root partition (just 60GB) was done in less than 10 minutes:

Linuxknoppix@Microknoppix:~$ dd if=/dev/sda1 of=/dev/sdb1 bs=1M
61440+0 records in
61440+0 records out
64424509440 bytes (64 GB, 60 GiB) copied, 408.774 s, 158 MB/s
knoppix@Microknoppix:~$ 
Muttering "Let fortune favor the foolish," I typed:
root@Microknoppix:/home/knoppix# e2fsck -y /dev/sdb1
e2fsck 1.44.5 (15-Dec-2018)
/dev/sdb1: clean, 309900/3909120 files, 5462752/15728640 blocks
root@Microknoppix:/home/knoppix# mount /dev/sdb1 /mnt
root@Microknoppix:/home/knoppix# ls /mnt
bin   etc    home            lib         media  proc  sbin  tmp  vmlinuz
boot  extra  initrd.img      lib64       mnt    root  srv   usr  vmlinuz.old
dev   foo    initrd.img.old  lost+found  opt    run   sys   var
root@Microknoppix:/home/knoppix# 
That may have been a little foolhardy, but I went to bed hoping for similar grace to befall on /home (over 800GB). The next morning, the copy was done. The news was happy:
root@Microknoppix:/home/knoppix# fdisk -l /dev/sdb
Disk /dev/sdb: 931.5 GiB, 1000207286272 bytes, 1953529856 sectors
Disk model: SanDisk SSD PLUS
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5fa89795

Device     Boot     Start        End    Sectors   Size Id Type
/dev/sdb1  *         2048  125831167  125829120    60G 83 Linux                 ← root partition
/dev/sdb2       125831168 1953529855 1827698688 871.5G  5 Extended
/dev/sdb5       125833216  159387647   33554432    16G 82 Linux swap / Solaris
/dev/sdb6       159389696 1953529855 1794140160 855.5G 83 Linux                 ← /home
root@Microknoppix:/home/knoppix# e2fsck -fy /dev/sdb6
e2fsck 1.44.5 (15-Dec-2018)
Pass 1: Checking inodes, blocks, and sizes
Inode 33692836 extent tree (at level 1) could be shorter.  Optimize? yes

Pass 1E: Optimizing extent trees
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/sdb6: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sdb6: 299071/56074240 files (1.4% non-contiguous), 54502379/224266934 blocks
root@Microknoppix:/home/knoppix# e2fsck -fy /dev/sdb1
e2fsck 1.44.5 (15-Dec-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb1: 309900/3909120 files (0.4% non-contiguous), 5462752/15728640 blocks
root@Microknoppix:/home/knoppix# 
Initial checks suggest that nothing important was lost. If something important had been lost, it would have been mightily inconvenient, but not really catastrophic. That said, I decided to add this device to my crashplan subscription.

Sunday, October 04, 2020

Collin reads the 2020 California ballot propositions

The following are of course just my opinions, informed by various biased information sources (all sources are biased, including yours)

Prop 14: authorize $5.5 billion in bonds for medical research

I think NO. Why bonds? If we want to spend money on research, just spend it; don't borrow it. This is like taking out a loan to fill the tank for the next year. I'm unconvinced by the proponents' arguments.

Prop 15: property tax on commercial and industrial real estate to be based on market value

YES. In the 1970s, proposition 13 was a bad idea (i voted NO), but only now do we understand the effect of REDUCING the property tax burden on businesses. When you or I buy a home, we buy it. When a company buys real estate, the company doesn't actually buy it; instead, there is some hocus-pocus by which the real estate doesn't legally change hands. Thus, those commercial and industrial properties that have different businesses on them than they did in the early 1980s—those properties are still owned by the same legal entities that are/were the landlords in the 1980s. Thus, the property tax burden on those parcels of real estate are based on the last "real" purchase, which was in the 1980s or earlier!

That's why homeowners now pay a higher share of the state's property tax burden then they did in the late 1970s.

It's time for businesses to pay their fair share of the property tax burden in California. Opponents say it'll increase the cost of doing business. Well, yeah. Failing to pass that will make it harder for your children and grandchildren to buy a home in California. What's more important? I've made my decision.

Prop 16: Make Affirmative Action Great Again

YES. Having read White Fragility and White Awake and the alarming statistics on racism's toxic effect on our country, I repent of my past opposition to race-based affirmative action.

The current ban on considering race, sex, color, ethnicity, etc. in public education, employment, contracting—the current ban is the way that the establishment is effectively saying "Keep Racism, Sexism etc. Alive!" It's time to reject that thinking.

Prop 17: Let parolees vote

YES. Parolees already have the deck stacked against them. Restoring their right to vote once they're "out" reduces recidivism. Let's give them a fair chance.

Prop 18: Let 17-year-olds vote in primary/special elections if they'll be 18 for the general

NO. Suppose this were the law in 2019. If you were born November 2, 1992, you could have voted in this year's primary election, but not if it were November 4th. So on March 3, you would have been 17 years and four months old.

Yeah, NO.

Prop 19: Close property tax loopholes

YES (as if you couldn't tell from the title I gave it). Why should inherited real estate be immune to reassessment— other than what's used for a home, I mean? Suppose a guy has bought two houses: one where he lives, purchased in the 1980s for about $125K, and another as a rental, purchased in 2000 for about $400K. When he and his wife die, the houses will likely be worth substantially more than what he paid for them. Suppose his heirs move into the family home, and keep the rental as a rental.

Both houses have changed hands; why should either of them be immune from reassessment (for purposes of calculating property taxes)? Even if the family home isn't re-appraised or reassessed, why should the rental be immune? Prop 19 doesn't require the famiily home to be reassessed in this case, but it would allow the rental to be reassessed—as it should be!

Prop 20: Disallows parole for certain offenses; requires more DNA samples to be collected

NO. This is rather a tough one. Prisons are already overcrowded. For-profit prisons love this proposition. This increases costs of various kinds; where is the evidence that it will reduce crime or improve the chances of catching perpetrators of future crimes?

What makes this a tough one is the scary stories of crimes that are currently considered nonviolent. But on balance I still think NO.

Prop 21: Allows localities to have stricter rent control than state law

NO. This depresses new construction and new improvements. I understand that rents are too high, but the state already has rent control, and further depressing new construction is absolutely not the answer.

Prop 22: Let uber, lyft, doordash &c to continue exploiting drivers

NO. Just no. Drivers really are employees.

Here's an example. Suppose you're an uber driver in Monterey, and you get a fare around 10am. You don't know where the fare's destination is; all you know is that they want a ride somewhere. If they want to go to the beach or to Pacific Grove or Carmel, that's fine, but you don't want to drive them to SFO because you would miss your 1pm medical appointment. Suppose you say "yes" and you find out they really do want to go to SFO? If you reject them, uber *will* penalize you. You really are not a contractor.

Uber and Lyft and Doordash and their ilk are mis-characterizing their employees as contractors. This injustice was remedied by state law, but now they want to overturn the law so they can continue exploiting drivers.

Prop 23: Stricter requirements on kidney dialysis clinics

YES. Operators of these (mostly lucrative) clinics do not want higher safety standards because they want to keep milking this cash cow. But people die because of preventable screwups at these clinics. I remember reading about a case where some plastic tubing came loose during dialysis and sprayed blood all over the place. A tech grabbed it and reconnected it. The patient died a few days later from an infection.

If a certified MD had been present, could that have been prevented? Would stricter safety procedures have been in place? Maybe, maybe not, but given that no MD was required, and given the industry's opposition to prop 23, I have eto guess that lots of these clinics don't have MDs present during treatment.

Let's put patients ahead of profits—that's what I think

Prop 24: Amends consumer privacy laws

NO. The legislative analyst points out (p. 67 of your voter information guide) that privacy requirements will be loosened on some businesses that are currently subject to state standards. Today if a business buys/sells personal data of 50,000 consumers, households, or devices annually are subject to those standards. The propsition doesn't include devices in the count, and raises the annual threshold to 100,000. To me that's a red flag.

Prop 25: Support state law replacing money bail system

YES. Money bail is unjust discrimination, as state law recognizes. But the bail system keeps the bail bonds industry alive. That industry exploits the poor and has political power (because of the profits generated) to keep this exploitation going. End this unjust pilfering of the disadvantaged, I say!

Monday, August 31, 2020

pdftk to the rescue (or: how to sign a PDF using a pen)

From the manpage: “If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a simple tool for doing everyday things with PDF documents.”

True, but the usage isn't always intuitive. Well, maybe it would be if I did these things every day. Which I don't. This one thing, that I have to do every few months (trying to make it less frequent), goes something like this:

  • Receive a PDF; call it orig.pdf
  • print page 3, sign, and scan; call that sigs.png
  • Create a new PDF which is the old one for pages 1–2, the scanned image from the previous step, and the old one for page 4; save as signed.pdf
Here is my cheat sheet for next time:
$ convert sigs.png sigs.pdf
$ pdftk A=orig.pdf B=sigs.pdf cat A1-2 B1 A4 output signed.pdf
There. Now the next time I have to do it, I won't have to stare at the manpage and try to reconstruct this incantation.

Sunday, August 09, 2020

Some Words on Anxiety

I have been thinking lately about anxiety. You know what the Apostle Paul said about anxiety, right?
And, apart from other things, there is the daily pressure upon me of my anxiety for all the churches. Who is weak, and I am not weak? Who is made to fall, and I am not indignant?
2 Corinthians 11:28–29 (RSV)
That’s right; he felt the pressure, just like you do. You want people to choose love and faith and generosity, rather than indifference and fear and envy. You long to see Christ formed in them. And in these pandemic times, you can’t see them in person to encourage them, or hold their hands while you pray for them. Paul knew about that, too.
Night and day we pray most earnestly that we may see you again and supply what is lacking in your faith. Now may our God and Father himself and our Lord Jesus clear the way for us to come to you. May the Lord make your love increase and overflow for each other and for everyone else, just as ours does for you.
1 Thessalonians 3:10–12 (NIV 1984)
Is anxiety good then?

Well, it’s not really recommended. Another famous writing of Paul tells us not to worry about anything, but to pray about everything (Philippians 4:6–7). And the Lord Jesus himself told us,

So do not worry, saying, “What shall we eat?” or “What shall we drink?” or “What shall we wear?” For the pagans run after all these things, and your heavenly Father knows that you need them. But seek first his kingdom and his righteousness, and all these things will be given to you as well. Therefore do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of its own.
Matthew 6:31–33 (NIV 1984)
I’ll add a pastoral word here: Paul the Apostle himself was at times beset by anxiety, so he is not scolding us, wagging a finger as he lectures us about worry. Neither is the Lord Jesus assuming a punitive posture in this extract from the Sermon on the Mount. Rather, his attitude is more like this father, coaxing his child to take a first step:
This is the same Jesus who said, “Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you and learn from me, for I am gentle and humble in heart, and you will find rest for your souls. For my yoke is easy, and my burden is light.” (Matthew 11:28–30)

That invitation from our Lord is intended for everyone who is weary and burdened, for those “in ministry” and for those who don’t think of themselves that way. In other words, it’s for you and me.

So let us come to him, let us take another step to him. That, more than any of our accomplishments or possessions, is what pleases him, and what brings us life and peace.

Saturday, July 25, 2020

Ash Wednesday thoughts

[found on the Notes app on my phone, from February]

It was a good day to die, as Garrison Keillor said of that spring day in Minnesota, with the tomatoes just planted. His aunt was looking over her garden when her heart just decided to stop.

His monologue came to mind today, Ash Wednesday. “Remember that you are dust, and that to dust you shall return,” say the priests. It’s a good thing for me to remember, because like most Americans, I tend to ignore my mortality. But it struck me the other day that I probably have fewer than 10,000 of them left.

Indeed, as I’ve heard a few times recently, “Life is short. We don't have much time to gladden the hearts of those who walk this way with us. So, be swift to love and make haste to be kind.” (attributed to Henri-Frédéric Amiel)

I hope in this Lenten season that I’ll be diligent to do that.


At the end of his monologue, Keillor remarked that it was indeed a good day to die. And if a good day to die, how much more was it a good day to live?