My Best Teaching Is One-on-One

一対一が僕のベスト

Of course, I team teach and do special lessons, etc.

当然、先生方と共同レッスンも、特別レッスンの指導もします。

But my best work in the classroom is after the lesson is over --
going one-on-one,
helping individual students with their assignments.

しかし、僕の一番意味あると思っている仕事は、講義が終わってから、
一対一と
個人的にその課題の勉強を応援することです。

It's kind of like with computer programs, walking the client through hands-on.
The job isn't really done until the customer is using the program.

まあ、コンピュータプログラムにすると、得意先の方に出来上がった製品を体験させるようなことと思います。
役に立たない製品はまだ製品になっていないと同様です。

Monday, May 22, 2017

journal 20170522

So I think I'll start posting parts of my work journal.
作業日記の一部を公開しようと思うようになりました。

I'm still spinning my wheels.
まだ無駄作業ばかりです。

My last contract ended in March.
最後の契約が3月に終わったのです。

In complete rejection of logic and reason, I have not been burning myself out to find a new job.
完全に理と役から離れて、就職活動に無駄な力を尽くしていません。

I have a series of novels I want to write.
書いて公開したい連続小説があります。

Nobody but my oldest sister is reading them.
一番上の姉以外はだれも読んでくれていません。

After the contract ended, I've been stuck on a little side-tour.
契約が終わってから、寄り道に詰まっています。

I needed to calculate the calendar of the world where the first several stories take place.
小説の最初の話の舞台となる惑星の暦を計算しないと進めないものがあります。

Then I got really interested in the puzzle of adding double integer divide to the base wordset of the programming language Forth.
プログラミング言語フォース(「先へ」)の基本単語集に、倍範囲幅変数型の割り算計算機能を付け加えることの謎謎に夢中になってしまいました。

Last week, I pretty much proved to myself that there are no easy, fast, deterministic methods for division, the way there are with multiplication.
掛け算にあるような、簡単で早い決定経路型手順は割り算に無いことに、だいたい納得できるまであちこちを探って、自分なりに証明しました。

Not a mathematical proof, just finding a difficult problem that no one else seems to have solved.
正確に証明したのではありません。ただ、南海の問題にぶつかって、その問題を解決した人の情報がどうしても出てこないのです。

We humans intuitively use estimates when we divide large numbers.
我々人間は、大きい数字の割り算に手を付けると、無意識に推測して、概算の手順を使います。

We have the multiplication tables memorized, and we use those tables in division.
既に暗記済みの掛け算表を参考に、割り算を行います。

When doing this in computers, those tables can become larger than the entire memory of the old 8-bit processors.
コンピュータに割り算を実装すると、その掛け算表が一昔の8ビット中央計算装置の全記憶装置量を超えるほどの量になることがあります。

The Forth that needs the double length divide is an 8-bit CPU implementation.
この倍範囲幅割り算を必要としているフォース言語は8ビットCPUに実装したものです。

Fortunately, the size of the table depends on the numeric base you operate in.
幸いに、その概算表の量は数値表現の進法に決まっているものです。

The table for one digit of decimal math is not really big, only 100 elements:
十進法の一桁の場合は表が大きくありません。百個の要素だけです。つまり、


×0123456789
00000000000
10123456789
2024681012141618
30369121518212427
404812162024283236
5051015202530354045
6061218243036424854
7071421283542495663
8081624324048566472
9091827364554637281

But we are not talking about one digit of decimal math.
ただ、十進法の一桁の話ではないのです。

The smallest table we can do without using bit shifts is a table for one column of base 256 math.

ビットシフト演算なしで一番小さい表はなんと 256 進法の一桁の表です。

That means a table 256 wide and 256 deep. That's 65,536 16-bit integers.
つまり、 256 桁の 256 行の表です。 65,536個の 16 ビットの整数です。

I'm not going to reproduce that here, because I'm pretty sure it would give your browser fits, not to mention what it might do to blogspot's template engine.

ここで再現しようとありがたく思われないので、止めておきます。閲覧者のウェブプラウザには全く優しくないどころか、ブログスポットのテンプレートエンジンの結構ひどい扱いにもなります。

(Blogspot might accuse me of trying to DOS them, and you might accuse my of DOSsing you.)
(あなたにも、ブログスポットにも、攻撃と思われるかも知れません。)

Now the problem is the shifts. Left shifts are just doubling, so they are pretty cheap. It's just an addition.
ビットシフト演算が問題です。左シフトは倍の計算ですので、特に問題になりません。足し算だけです。

Unless you have actual bit shifts, shifting to the right is expensive, requiring a division.
ビットシフト演算がなければ、右にシフトするのは割り算の重たい計算がかかります。

It's a relatively cheap single-wide division, so it's not a chicken-and-egg problem, but even single-wide divisions take a long time on old microprocessors.
単幅の比較的に重たくない割り算ですので、鶏と卵のような問題ではありません。と言っても、古いマイクロプロセッサーには結構の暇が掛かります。

Addition on old microprocessors takes maybe ten microseconds. Division takes easily 200 times that.
古いマイクロプロセッサでは、足し算は凡そ十ナノ秒(一秒の十万分の一)しか掛かりません。割り算は辛うじてその200倍がかかります。

It's possible to use scaling to reduce the amount of math required without the tables, but scaling requires shifting as well.
表無しでよろうと思えば、スケーリングという尺度合わせのような手もあります。但し、これにもビット演算が必要です。

Binary division is different. This is all there is to the table:
二進法の割り算は違います。これだけの表です。

×01
000
101

And binary division is just shifting, subtracting, and counting.
そして、二進法の割り算はただシフト演算と引き算と回数の一をとることで済ませる。

It's slow, but it's straightforward.
ゆっくりと出来上がりますが単純な決定経路型手順です。

So, if I have to use shifts anyway, I may as well go down to the machine level and implement the division in assembler anyway.
なるほど、シフトをもって実装するしかないなら、もう、低レベルアセンブリ言語で割り算そのものを実装するほうが懸命ではありませんか?

[JMR201706171513:

I have the program running, and it produces monthly calendars for the planet that I think are accurate. The source can be found, complete with the code for dividing double integers, in my Xhilr Calendar workspace at OSDN Japan.
暦作成のプログラムは稼働できます。その惑星の正確性在るとボクが思っている月毎のカレンダーが作成できます。倍幅割り算を含めたソースコードをボクの OSDN Japan 上の Xhilr Calendar 作業部屋に置いています。

]

This is not the way a sane person spends his time when he needs to be finding a new job, you know.
新しい仕事を探しているはずの正気の人がやるようの人生の過ごし方ではありません。ね。

Last Sunday, I went to the special stake conference in Kõbe and listened to Elder Oaks and other Church leaders.
先の日曜日は、特別ステーク大会のために神戸に行って、オークス長老と他の教会指導者の話を聞きました。

I'm feeling much less down.
ちょっと立ち直りました。

Monday, May 15, 2017

Do Not Pay the Modern Danegeld! -- Ransomware

Yesterday, I read in the paper how ransomware has been spreading.

It would be easy to waste electrons castigating Microsoft for leading the establishment of impossible-to-secure software as industry standards.

(The words "unsafe at any speed" make me wonder why Nader has been mostly silent about the current computer industry.)

It is true that software, including operating systems, is not exempt from the mathematical principle that absolute security is an internally inconsistent concept.

But the habit of the industry has been to rely on lack of education rather than actual prevention.

This combined with excessive competition for the market has led to unsafe practices built on unsafe features built on unsafe practices.

We all know that our information devices are unsafe -- impossible to secure. (Or, if you do not, you have been deliberately closing you eyes. Perhaps you think there is nothing to do about it.)

So, now someone you know is looking at a message on his or her screen:

Pay up or lose your precious data!
You seriously can't be thinking
$300 is cheaper than losing my mail archives and address book!
Let me put the real costs in front of you:

Every dollar you give in ransom is the price of one bomb or landmine, small enough to hide, large enough to kill and maim humans and animals, large enough to destroy or disable cars, trucks, roads, communication lines, etc.

Every bitcoin paid in ransom is 1,700 such bombs.

And if you pay it now, you will be faced with paying it again.

What should we do?


Step back, take a deep breath, let common sense flood back into your brain.

  • Do you have backups?

If not, now is the time to start planning.

  • Can you reconstruct the data?

Re-constructing the data may take time, but if you can't reconstruct your data, it was never yous in the first place.

("Big Data" is a comfortable illusion with some substantial features, but you really should be honest with yourself about that. Money doesn't really grow on data trees, whether binary, b-star or otherwise.)

  • Okay, you have partial backups -- USBs, dropboxes, cloud services, etc. 
  • And you can reconstruct the most important data, if you are willing to take the time. 

So, no, the data that has been locked away from you is not worth continuing to arm the enemy.

  • First step, shut that computer off. 

If you have reason to believe that the ransomware will try to delete data on shutdown or some such stupidity, pull the plug and the batteries.

Your local geek may be worried about data loss on shutdown, but the converse is also a problem. Hiding is easy, but encryption takes time.

Remove all hard disks, SDs, and USB storage devices that were attached when the malware showed up, and collect all external storage that has been attached to the infected device in the past week, at least.

Learn something about security. Do not depend on books with names like "Security for Dummies." Dummies are soon chumps, and that's how you got in this mess.

Yes, I should write a book. Somebody front me the money. Oh, well, that's not happening very soon.

Two of my blogs, free is not free, and defining computers have some useful information, but some of it is old, and both mix rants, daydreams, and parable with practical advice.

So use your own brain. Here's a start:
  1. Think about what secrets are. 
  2. Think about what computer data is.
  3. Think about walls and locks
  4. Think about protocol.
Think about what the limits of the above are without computers. Then convince yourself that computers are not magic. Fast and re-writable, but not magic.

I'll list a few really relevant rants:

Back to practical steps:

  • Re-flash the BIOS of the infected device. 

If you don't do that, you're likely to get re-infected. BIOS attacks are becoming commonplace, and the ransomware attacks are at that level.

(And, yes, there are indeed huge problems in the new BIOSses. Reflash or buy new, but buying new is a problem, too.)

  • Install new boot and other internal media (new hard disk or SD for boot and data) and install a new, safer OS.

I'd recommend a Linux OS such as Debian, Ubuntu, or Red Hat Linux, but, really, the marketplace has been infecting those with unsafe applications, practices, and features for the last fifteen years.

Eventually, I want to recommend installing a Linux or BSD OS and installing MSWindows in a VM on top of that, but that is not yet ready for prime time, and Microsoft and Intel seem to think they have financial incentives in working behind the scenes to make that not happen.

If you have to use a Microsoft OS, just don't keep important data on it, especially not without backup.

  • Make a plan about where to store your data.

As much as it galls me to say so, yes, I'm suggesting NAS and cloud if you have any really valuable data.

At bare minimum, keep copies on USB drives that you properly unmount before removing. (Click the "remove" button and wait until the OS says it's okay.) And do not keep the USB drive inserted in the computer while you work.

Do not keep any valuable data on your workstation. (I say, but I can't afford to do otherwise right now. I'll have to take my own advice and collect my data onto an external device, as soon as I get some résumés sent out. But I'm using an OS I'm fairly confident I can still trust.)

  • Take a little time to review what you think you know about computers on a regular basis. Learn an alternative OS.
And
  • Take time to understand your data, what you have, and what it's worth.
Now that we have that out of the way, now is the time to think about recovering that locked-up data.

  • First, mount the media device (hard disk, SD, USB) on a known-safe machine. 
  • Then look around and see what was actually encrypted and what was just moved somewhere.
  • Then go look for tools for un-erasing data. The attackers may not have encrypted the partitions, and probably has not tried to find deleted files to encrypt. So you will likely be able to recover up until the last save, even if the encryption really is unbreakable.
  • Finally, if you still have data that is highly valuable and not recovered, now you know how much you will be willing to pay a legitimate professional to try to get it back by brute-forcing the encryption keys.
That last list is the one you wanted me to tell you first. But that would not be helping you to be secure the next time, and the next time is already waiting for you.

Thursday, May 11, 2017

Visions and Pioneering and Responsibility to Family

I was talking with some members of the Forth community on comp.lang.forth about using floating point numbers in a Forth language, and thinking about how I really don't much care for floating point math in programming languages.

Arbitrary precision is much more what most people want. It's a little slower than floating point, but it has fewer surprises. (There are still some surprises induced by the fact that computers do not easily extend precision, where we on the other hand are quite happy to grab another piece of paper and keep going until our wrists get sore or we fall asleep -- or get bored.)

Fixed precision is much faster and much lighter on computer resources. With 64 bit math on modern computers, we can easily do math to 18 decimal places. That would cover most peoples yearly budgets, easily.

But, for all that fixed precision would cover most daily calculation needs, it requires us to keep track of precision ourselves. That's why arbitrary precision and floating point are useful.

Floating point would be a bit easier if it weren't for all the bit fields that have to be extracted from memory that don't fall on easily addressed boundaries.

Then I had this idea about having the exponent be in one integer and the fractional part be in another. That would give ridiculous range for 16-bit CPUs (like 10 followed by more than 16,000 zeros). The fraction part would give us one part in 65536, or a bit more than four digits on the right of the decimal point, which isn't enough for some things, but is plenty for others.

On 32 bit CPUs, the range would be even more ridiculous, but we would have about nine digits on the right of the decimal. Which is why floating point fields don't fall on even boundaries.

On 64 bit CPUs, the range would be beyond ridiculous. Billions of zeros. But the fractional part would be more than 18 digits, which is pretty decent.

The discussion on comp.lang.forth focused on the problem of knowing just how wide a floating point number on the top of the stack of recently used numbers is. When working on the stack, you need to know the size of the numbers that are on the stack so you can get them off the stack and get around them to other numbers, and so forth.

It occurred to me that a floating point number that could tell the programmer how wide it is would be rather useful.

And this first-blush byte format came to mind, just before I went to bed:

8888 8888
length = 0
(8 bits)
exponent (24 bits)fraction (32 bits)

And, in fact, it kept me up a bit, re-thinking things:

8888 8888
sign
(high bit),
length = 0
(7 bits)
exponent (24 bits) fraction (32 bits)

And then it was

8888 8888
sign
(high bit),
length = 0
(7 bits)
exponent
(8 bits)
fraction
(16 bits)
------
sign
(high bit),
length = 1
(7 bits)
exponent (24 bits) fraction (32 bits)

Where length of 0 would be a special case, with the whole floating point number contained in a single 4 byte (32 bit) unit.

From length 1 on, the length would be the count of 32 bit units containing the fractional part (or mantissa, I have to figure out details later), and the three bytes after the length byte would be the exponent.

Checking the IEEE floating point specs on Wikipedia, none of the most common formats have more than 15 bits of exponent. The standard 32-bit format has only 7 bits of exponent, and the standard 64-bit format has only 11 bits of exponent. So 24 bits of exponent is plenty.

Maybe I can scrape the top two bits of the exponent off for flags of some sort. 22 bits of exponent still gives an exponent range of 10 followed by two million zeros.

Speaking of zeros, being able to specify up to 127 times 32 bits of mantissa means ( 127 × 4 == 508 bytes, or 1016 nibbles) better than 1100 decimal digits worth of accuracy in decimal terms.

That's going to be enough to satisfy most mathematical needs for primary grades through college, except for certain engineering purposes.

Mathematically, it's a loose fit, but, with everything falling on nice byte boundaries, it's going to be a lot less work up front.

A similar approach could be used for decimal or other base digits, which is something to think about later.

It will be a little slow, since it will be implemented in software, but you can extend the numbers, mid calculation, to avoid losing precision.

And, randomly associating, a similar approach could be taken with text strings, if we had a better way of representing numbers in the middle of text (a topic which I really want to rant on sometime).

You can probably get a sense of what this has to do with pioneering (ergo, new or less-explored computer/data techniques), but what does this have to do with visions and responsibility to families?

I really should not be typing this.

I really should be running around like a chicken with its head cut off trying to scrounge up work for when my savings runs out in another month.

I am being irresponsible.

I woke up this morning at three thirty, still thinking about this stuff.

And I was thinking about Nephi, in the Book of Mormon, 1 Nephi 17: 9, asking God where to go to get ore to make tools to build the ship with.

Now we have to understand the story. Nephi had been helping his father get their families moved across the desert towards the sea. He had done his part in making sure that the women and children had enough to eat. They had found a nice place on the sea shore to settle down and maybe be safe from the Babylonians and others whom the prophets had been foretelling would be coming to take Jerusalem down for real this time.

Now, he was getting inspired to take the whole group on a long adventure into the unknown, across the sea to a land he and his father had seen in dreams.

His older brothers were upset, and we can understand why.

I am being inspired to take my family on a long adventure into uncharted territory with my writings and other dreams, visions, fantasies, and delusions such as the above. My family is understandably upset.

(Delusions. Ask pretty much anyone, and they will tell you that someone like me should not working with all the wonderful technology that is out there for the using. We have floating point. We have arbitrary precision math. We have the Unicode character set. We have programming languages and CPUs.

What need have we of more of these?

(Other than that it is a deliberate mess, designed to keep the riff-raff like you and me from using it to make the world a better place.)

Well, Nephi asked God where he should go to get ore for tools.

I have been asking God where I should go to get funding.

There is a bit of difference.

Nephi had done his part in securing food and a place for his family. My family and I are on the brink.

He was looking for ore for tools. I am looking for money for a place, for food, and for tools.

This is scary business.

Visions, pioneering, and responsibility to family.