How to redirect command output to an unnamed file descriptor in bash, so you can use the output easily for fd-only commands (e.g. diff two strings in bash).
pkgs_remote=$(ssh ${HOST_OLD} rpm -qa | grep -Ei '(httpd|php)' | sort)
pkgs_local=$(rpm -qa | grep -Ei '(httpd|php)' | sort)
diff <( echo ${pkgs_remote} ) <( echo ${pkgs_local} )
Barring industry/product demand transformations where demand dwarfs the existing labor supply, it seems that since the Industrial Revolution, we've seen increasing amounts of human capital required to get pretty much anywhere you want. Essentially, it seems like all the low-hanging fruit have been picked, and we need to gear up to reach the tasty heights.
I worry that many college graduates are unsettled nowadays because they did not really learn much.
I hate it when I have a complex bash script that I need to run and it has lots of steps in it, any one of which can fail. However, NOT re-running all the previously succeeded steps seems efficient. And in some circumstances, running any previous steps prove catastrophic.
I could just run the script and hope it works, and when it fails, fix the failing bits, while removing the already run code, but keeping the variable declarations.
Or I could source this bash script. ;)
#!/bin/bash
set -o functrace
set -o history
set +o noclobber
shopt -s extdebug
[[ ${BASH_VERSINFO[0]} -lt 4 ]] && {
echo "BASH Version 4 or higher required by idempotency.sh"
exit 1
}
idem_debug() {
[[ "${DEBUG}" != "" ]] && echo "$@"
}
idem_is_command() {
local cmd="$( echo "$1" | awk '{print $2}' )"
command -v "$cmd" >/dev/null 2>&1 && return 0
[[ -z "$( which "$cmd" 2>/dev/null)" ]] && return 1
return 0
}
idem_debug "idempotency using source file '${0}'"
idem_dir="${0%\/*}"
[[ "${idem_dir}" == "" ]] || [[ "${idem_dir}" == "$0" ]] && {
idem_dir="."
}
idem_debug "idempotency using source dir '${idem_dir}'"
idem_file="${idem_dir}/.${0/#*\/}.idempotent"
idem_debug "idempotency using history file '${idem_file}'"
idem_trap() {
local cmd=$(history 1)
idem_debug "idempotency checking command '${cmd}' subpart '${BASH_COMMAND}'"
[[ "${idem_last}" == "${cmd}" ]] && {
idem_debug "idempotency not re-checking subshell/pipe breakdown for '${BASH_COMMAND}'"
return 0 # return ok
}
! idem_is_command "${cmd}" && {
idem_debug "idempotency running non-command '${cmd}'"
return 0
}
export idem_last="${cmd}"
[[ -f "${idem_file}" ]] && grep -qF "${cmd}" ${idem_file} && {
idem_debug "idempotency not running previously run command '${cmd}'"
return 1 # don't run the command again
}
echo "${cmd}" >> ${idem_file}
idem_debug "idempotency running command '${cmd}'"
return 0
}
trap idem_trap DEBUG
It uses the preexec hack idea from glyph, and I need to write a bunch of tests for it.
I told him about how whole mornings disappeared that way. I pictured a guy looking for his keys so he could get his day started, but he searched by lifting up every item he owned to look under it. Not under the rug. Not under the fridge. Not under the laundry, or the paperclip on my desk. Not under the silverware tray in the top drawer on the left in the kitchen. Maybe I should check the rug again?
Morning rituals seem retardly important. Over the last week, I've taken to grabbing a Red Bull and walking to work early. When I was in Salzburg, it was matins at the Stiftskirche Nonntaler followed by Semmeln und Kaffee. Back in PA, it was a cold can of Mountain Dew.
Less charitably, I think to myself that it's not the ritual, stupid; it's the caffeine. ;)
The
New Financial Order by Robert Shiller
Technocracy-Optimist Shiller describes several financial innovations he'd like to see deployed, and the relevant histories of the ideas. He sees only good in his ideas and does not try to weigh out the pros and cons. E.g. on the ability of governments to track citizens' cash flows.
The inability of citizens to evade and cheat offers opportunities for social planners. We will be able to achieve a more equitable income distribution because we will be observing it more accurately.
While governments continue to fund criminal enterprises with blanket prohibitions, it seems likely to me that there will be a continuing war of advances and countermeasures in laundering money.
Given this one-sidedness, his histories of financial innovation provide the best reading:
A breakthrough of worldwide significance occurred in the United States with an 1811 general act of incorporation in New York State. Not only did the act set the precedent of allowing any business that satisfied minimum requirements to incorporate, but it also initiated the radically new step of specifying that all investors in New York corporations have strictly limited liability. Before this act corporations were usually creatures of government, enjoying a government-sanctioned monopoly, and incorporation ws not available to business at large. Moreover, creditors of failing companies could in principle seize all the personal assets of each stockholder, even those holding few shares, until the debt was repaid.
Knowing this makes the first chapters of PanicOnWallStreet more intelligible.
Andrew Lo and Mark Mueller have a paper out, titled Warning: Physics Envy may be Hazardous to your Wealth!.
Basically, this paper inadvertently says two things: 1) study your history, 2) take a physics approach to finance.
If, over a 70-year period, the U.S. did not experience a signicant national-level decline, how could the possibility of such a decline be factored into the analysis?
If Tycho, Kepler, Galileo and Newton had been confronted with such "quasi-periodic" data for the cyclical paths of the planets, it may have taken centuries, not years, of observational data for them to arrive at the same level of understanding of planetary motion that we have today.
Of course, von Neumann provides the fitting closing:
"If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is".
Anathem by Neal Stephenson
Printer totally ruined it by having the geometric proof of Pythagoras' theorem on page 344. Aside from that, monks on math makes for a surprisingly good read.
"Our opponent is an alien starship packed with atomic bombs. We have a protractor."
dreamt I was walking along the marina and an ex-pat friend flounced up to me, saying that her boyfriend had found a new bank scam for DBS bank. Part of me was interested, and part of me was "she's probably dating some pudgwick with a scam2.". The interested part won, and we went back to her new offices, where I saw a worker scraping off the DBS insignia from the main door.
Pudgwick was on the phone, so I wrote "DBS Scam?" on the wall, only I kept being dyslexic, so that I had to write one letter ( I wasn't sure what letter would appear), then based on the letter, write another letter on the side with better odds, and repeat until I had written "DBS", for some reason I had no problem writing "Scam ?". I then looked over at Pudgwick, who saw my note and started to say something.
That's when I woke up. lol.
dreamt I was in class again and someone was presenting a graph of year-over-year percentage changes in something. I said that was bad UI, because 1) -50% followed by +50% does not equal no change, and 2) to track changes, e.g. -10% down for month M in year Y followed by -10% down in month M in year Y+1, means you have to compound. Both of these imply putting a cognitive burden on the graph viewer as they play the graph from their own points of reference in time.
Some guy hotly contested this, so I had to walk through a demonstration of why it sucked. Three-quarters of the way through the demo, he figured it out and shut up.
dreamt of a black blank space, a high-pitched voice was calling out for everyone to view the death-defying feats of a high diver. Standing upon his perch, the high diver beseeched us for donations, below bonds were being written upon his life and money was flowing in. As he waved, he mentioned his underling, his brother, and his underling's underling, his youngest brother. Looking over the bonds, money, and brothers, I realized that this act was suicidal. And then he leapt.
The paper said he died of a ruptured spleen. The accompanying photo showed a man decapitated at the jaw. I woke up and could not immediately sleep.