Wednesday, September 13, 2017

Massimo Banzi (Arduino) Bookshelf

  • Out of Control
  • Art of the Digital Age (Bruce Wands)
  • Total Interaction
  • Designing Interactions (Bill Moggridge)
  • The semantic turn
  • METAMAGICAL THEMAS (Douglas Hofstadter)
  • Human-Computer Interaction
  • Physical Computing
  • past tense, future sense
  • DEUTSCHE STANDARDS
  • pROCESS
  • Open Design Now
  • World Changing - a User's Guide for the 21st Century (Alex Steffen. "passivhaus buildings, biomimicry, intros by Van Jones and Bill McKibben (350.org) )
  • Paper Prototyping (about designing user interfaces) (Carolyn Snyder)


Thursday, August 17, 2017

How to Be a Good Codebreaker : Wolf (William) Friedman

Under mental equipment he would also include the faculty of being able to concentrate on a problem for rather long periods of time, without distraction, nervous irritability, and impatience. The strain under which cryptanalytic studies are necessarily conducted is quite severe and too long-continued application has the effect of draining nervous energy to an unwholesome degree, so that a word or two of caution may not here be out of place. One should continue at work only so long as a peaceful, calm spirit prevails, whether the work is fruitful or not. 'But just as soon as the mind becomes wearied with the exertion, or just as soon as a feeling of hopelessness or mental fatigue intervenes, it is better to stop completely and turn to other activities, rest, or play. It is essential to remark that systematization and orderliness of work are aids in reducing nervous tension and irritability. On this account it is better to take the time to prepare the data carefully, rewrite the text if necessary, and so on, rather than work with slipshod, incomplete, or improperly arranged material.

https://www.nsa.gov/portals/75/documents/news-features/declassified-documents/military-cryptanalysis/mil_crypt_I.pdf

How Will You Find the Longest Words Shakespeare Used (Perl)

  1. Get them text from : https://ocw.mit.edu/ans7870/6/6.006/s08/lecturenotes/files/t8.shakespeare.txt
  2. vi ./shakesp.txt    # get rid of the obviously easy stuff - a look through tells you up to what point (sonnets start) you can safely delete :)
  3. perl -n -000 -e 'print unless /^\s*\d+\s*$|ELECTRONIC|^\s*the\s+end\s*$|project\s+gutenberg|etext/i;' ./shakesp.txt > shakeclean.txt
  4. perl -p -e 's/[^a-zA-Z\047]/\n/g; s/(.)/\L$1/g;' shakeclean.txt | perl -nl -e 'chomp; print if length > 13;' | sort | uniq | perl -n -0'' -e '@words = split( "\n" ); @sorted = sort { length $b <=> length $a } @words; $longest = join "\n", @sorted; print "$longest";'
honorificabilitudinitatibus (Love's Labour Lost)
anthropophaginian
indistinguishable
undistinguishable
incomprehensible
superserviceable
circumscription
disproportioned
distemperatures
distinguishment
enfranchisement
excommunication
extraordinarily
flibbertigibbet
impossibilities
indistinguish'd
interchangeably
interchangement
interrogatories
misconstruction
notwithstanding
particularities
perpendicularly
portotartarossa
praeclarissimus
prognostication
superstitiously
transformations
uncompassionate
uncomprehensive
undistinguished
unreconciliable
accommodations
accomplishment
acknowledgment
administration
affectionately
apprenticehood
carnarvonshire
circumstantial
consanguineous
considerations
conspectuities
constantinople
contemptuously
contumeliously
correspondence
counterfeiting
determinations
discomfortable
discontentedly
disparagements
distemperature
entertainments
fortifications
halfpennyworth
handicraftsmen
imperceiverant
inconveniences
insurrection's
intelligencing
inter'gatories
interpretation
leicestershire
mephostophilus
nebuchadnezzar
northumberland
oscorbidulchos
preposterously
principalities
proportionable
reconciliation
sovereignvours
superscription
transformation
unaccommodated
understandings
unpremeditated
unproportion'd
unquestionable
unthankfulness
voluptuousness

Saturday, August 12, 2017

Oh For a Better Python Debugger

Are there any debuggers that, when they tell you they run into an issue when you did "continue" can also tell you what steps to take to get the line before you get the problem?

Someone should make one and upgrade the pdb likewise.

Wednesday, August 09, 2017

The Underwhelming Genius of Guido van Rossum's Underlings

$ pip install XlsxWriter
Requirement already satisfied: XlsxWriter in c:\users\USERNAME\appdata\local\programs\python\python35-32\lib\site-packages

$ python -m XlsxWriter
/usr/bin/python: No module named XlsxWriter

Why can't python or even pip for that matter put out a warning about PYTHONPATH? What single mom with three kids and a mortgage needs to find out she has cancer before they put this in?

Das mensch suggests python -m pip install is a panacea. Really?

 $ python -m pip install XlsxWriter
Collecting XlsxWriter
  Using cached XlsxWriter-0.9.8-py2.py3-none-any.whl
Installing collected packages: XlsxWriter
Successfully installed XlsxWriter-0.9.8
 $ python -m !$
python -m XlsxWriter
C:\Users\USER\AppData\Local\Continuum\Anaconda3\envs\aind\python.exe: No module named XlsxWriter

WT*!!??

Okay, reading and reading and reading (for all the protesting CS folks do about user experience, when it comes to free stuff, unless you're the product (think GOOG)) you get what you pay for. Why can't they issue a warning saying (say) "importing usually uses the name in lowercase completely". Why not ease the pain?

So, if I set my PYTHONPATH and then do python -m xlsxwriter.worksheet, I actually do get something.. 

Getting Windows and Cygwin to Behave and then Using du for Disk Space Accounting

One use of Cygwin Windows can't match (I mean a unix feature Redmond hasn't heard of) is du

Your disk space is running low and of course Windows gives you accounting info - accurate but useless info - it doesn't tell you who the culprits are..

Unix - via Cygwin can help

But...

user@host /cygdrive/c
$ echo  `ls -d */ | grep ocumen | perl -p -e 's%/.*$%%;  s/\h/\134 /g;'`
Documents\ and\ Settings

user@host /cygdrive/c
$ du -ks  `ls -d */ | grep ocumen | perl -p -e 's%/.*$%%;  s/\h/\134 /g;'`
du: cannot access 'Documents\': No such file or directory
du: cannot access 'and\': No such file or directory
du: cannot access 'Settings': No such file or directory

Smell a rat? It's been bugging me for too long..

The ultimate goal is to be able to do $ for dir in `asdfdas` ; do ; du -ks $dir ; done ... But, it's turning out to be harder than I thought..

Here's the other problem. You do

$ for dir in `ls -d */` ; do ; echo $dir ; done
you get

Documents
and
Settings

which will make du curse you. Here's my workaround : 

for dir in `ls -1 -d */ | perl -p -e 's@/.*@@; s/\h/\%20/g; '`
do
tdir=`echo $dir | perl -p -e 's/%20/ /g;'`
du -ks "$tdir"
done

You're first giving bash's for loop a list with spaces in filenames substituted with %20. This is just so the for loop behaves (yes, you can mess with the IFS variable)
Then, you create a variable with the filename restored.
Then you call du on this new variable

Sunday, July 30, 2017

Inspire Your Co-Workers with a Screensaver

So you want to display quotes on your computer's locked screen when you're not at your desk. There's one way I know. Looking for a powerpoint that will sequence through slides like in kiosk mode? Sorry, that's not an option (yet) in Windows 10 for the lock screen.

Save your ppt as JPEG images (File > Save As > change the format - the name you provide will be a folder containing each slide)

That done, click on the Window (Start button) on the left of your taskbar and then on the Gear (settings). You'll launch Windows Settings.

Here, in the search box, type "lock" (it might suggest "add a folder to your lock screen slideshow", but don't jump the gun.

At the new menu, change the "Background" option from "Windows Spotlight" to "Slideshow" (drop down)

Then, under "Choose albums for your slideshow", add your new folder.

Then, click on "Advanced slideshow settings" and adjust "When my PC is inactive, show lock .." and "Turn off screen after slideshow has played for".. to your choice.

And that's it. Hit WIN-L and see the result!

Yes, the slides will be displayed in random order - nothing you can do about that :(

Thursday, July 27, 2017

Perl Insert Contents of One File Into Another at Line Matching Regex

Nice to have something I think is better than stackexchange - how often does that happen :) ?

To insert after a line matching the regex

perl -n -i -e 'print; print `cat FILE_TO_INSERT` if m#REGEX_TO_MATCH#; ' FILE_TO_MODIFY

To insert before :

perl -n -i -e 'print `cat FILE_TO_INSERT` if m#REGEX_TO_MATCH#; print;' FILE_TO_MODIFY

If you want the insertion to happen at the first match ONLY :

perl -n -i -e 'print `cat FILE_TO_INSERT` if m?REGEX_TO_MATCH?; print;' FILE_TO_MODIFY

A very valid question is, what do you do if your match pattern has the question-mark character? :)

https://unix.stackexchange.com/questions/32908/how-to-insert-the-content-of-a-file-into-another-file-before-a-pattern-marker

Saturday, July 08, 2017

A (Relatively) Low IQ Not Apparent in a Prepared Speech

Man, what a nice speech - he's succinctly put all 3 things together - Versailles > War > Lebensraum > the problem necessitating the formation of NATO. One thing missing is the human emotions that caused WW1 to happen in 1914 in the first place. When is being swollen-headed a crime? When is it a crime to want your own "place in the sun"? Is military-posturing a crime against peace if it is likely to lead to war? And he conveniently leaves out his role in the Final Solution as well.

Herr Ribbentrop :

This Trial will go down in history as a model example of how, while appealing to hitherto unknown legal formulas and the spirit of fairness, one can evade the cardinal problems of 25 years of the gravest human history.

If the roots of our trouble lie in the Treaty of Versailles--and they do lie there--was it really to the purpose to prevent a discussion about a treaty which the intelligent men even among its authors had characterized as the source of future trouble, while the wisest were already predicting from which of the faults of Versailles a new world war would arise?

I have devoted more than twenty years of my life to the elimination of this evil, with the result that foreign statesmen who know about this today write in their affidavits that they did not believe me. They ought to have written that in the interests of their own country they were not prepared to believe me. I am held responsible for the conduct of a foreign policy which was determined by another. I knew only this much of it, that it never concerned itself with plans of a world domination, but rather, for example, with the elimination of the consequences of Versailles and with the food problems of the German people.

If I deny that this German foreign policy planned and prepared for a war of aggression, that is not an excuse on my part. The truth of this is proved by the strength that we developed in the course of the second World War and the fact how weak we were at the beginning of this war.

History will believe us when I say that we would have prepared a war of aggression immeasurably better if we had actually intended one. What we intended was to look after our elementary necessities of life, in the same way that England looked after her own interests in order to make one-fifth of the world subject to her, and in the same way that the United States brought an entire continent and Russia brought the largest inland territory of the world under their hegemony. The only difference between the policies of these countries as compared with ours is that we demanded parcels of land such as Danzig and the Corridor which were taken from us against all rights, whereas the other powers are accustomed to thinking only in terms of continents.

Before the establishment of the Charter of this Tribunal, even the signatory powers of the London Agreement mast have had different views about international law and policy than they have today. When I went to see Marshal Stalin in Moscow in 1939, he did not discuss with me the possibility of a peaceful settlement of the German Polish conflict within the framework of the Kellogg-Briand Pact; but rather he hinted that if in addition to half of Poland and the Baltic countries he did not receive Lithuania and the harbor of Libau, I might as well return home.

In 1939 the waging of war was obviously not yet regarded as an international crime against peace, otherwise I could not explain Stalin's telegram at the conclusion of the Polish campaign, which read, I quote:

"The friendship of Germany and the Soviet Union, based on the blood which they have shed together, has every prospect of being a firm and lasting one."

Here I should like to emphasize and stress the fact that even I ardently desired this friendship at that time. Of this friendship there remains today only the primary problem for Europe and the world: Will Asia dominate Europe, or will the Western Powers be able to stem or even push back the influence of the Soviets at the Elbe, at the Adriatic coast, and at the Dardanelles?

In other words, practically speaking: Great Britain and the United States today face the same dilemma as Germany faced at the time when I was carrying on negotiations with Russia. For my country's sake I hope with all my heart that they may be more successful in their results.