<?xml version="1.0" encoding="utf-8"?>
<!-- If you are running a bot please visit this policy page outlining rules you must respect. https://www.livejournal.com/bots/ -->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:lj="https://www.livejournal.com">
  <id>urn:lj:livejournal.com:atom1:aaronhawley</id>
  <title>refusal computing</title>
  <subtitle>Aaron S. Hawley</subtitle>
  <author>
    <name>Aaron S. Hawley</name>
  </author>
  <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/"/>
  <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom"/>
  <updated>2015-01-26T20:02:12Z</updated>
  <lj:journal userid="14167250" username="aaronhawley" type="personal"/>
  <link rel="service.feed" type="application/x.atom+xml" href="https://aaronhawley.livejournal.com/data/atom" title="refusal computing"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:31497</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/31497.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=31497"/>
    <title>User liberation: New video from the FSF</title>
    <published>2015-01-11T21:47:17Z</published>
    <updated>2015-01-26T20:02:12Z</updated>
    <category term="unix"/>
    <category term="free software"/>
    <content type="html">&lt;lj-embed id="5" /&gt;

&lt;p&gt;from &lt;a href="https://www.fsf.org/blogs/community/user-liberation-watch-and-share-our-new-video" target="_blank" rel="nofollow"&gt;fsf.org community blog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The last 45 seconds is pretty cool.  There's a build of &lt;a href="http://gstreamer.freedesktop.org/" target="_blank" rel="nofollow"&gt;Gstreamer&lt;/a&gt;, interspersed with screenshots of &lt;a href="http://www.gnome.org/" target="_blank" rel="nofollow"&gt;Gnome&lt;/a&gt;, &lt;a href="http://www.pitivi.org/" target="_blank" rel="nofollow"&gt;Pitivi&lt;/a&gt;, &lt;a href="http://www.blender.org/" target="_blank" rel="nofollow"&gt;Blender&lt;/a&gt; and &lt;a href="http://inkscape.org/" target="_blank" rel="nofollow"&gt;Inkscape&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The work is licensed under &lt;a href="http://creativecommons.org/publicdomain/zero/1.0/" target="_blank" rel="nofollow"&gt;CC0&lt;/a&gt; and the FSF is looking for other translations.  Currently, only French and the original English are available.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:31350</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/31350.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=31350"/>
    <title>Javascript serenity prayer</title>
    <published>2013-12-26T22:05:17Z</published>
    <updated>2013-12-26T22:05:17Z</updated>
    <category term="twitter"/>
    <category term="programming languages"/>
    <content type="html">I'm going to make this my New Year's resolution as well:

&lt;p&gt;&lt;a href="http://twitter.com/eric_s_smith/status/415839082099404800" target="_blank" rel="nofollow"&gt;&lt;img src="https://ic.pics.livejournal.com/aaronhawley/14167250/1231/1231_original.png" alt="Javascript serenity prayer" title="Javascript serenity prayer" fetchpriority="high" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
God, grant me serenity to accept the Javascript I cannot change,&lt;br /&gt;
The courage to change the Javascript I can,&lt;br /&gt;
And wisdom to know the difference.&lt;br /&gt;
-- &lt;a href="http://twitter.com/eric_s_smith/" target="_blank" rel="nofollow"&gt;@eric_s_smith&lt;/a&gt;
&lt;/blockquote&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:30888</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/30888.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=30888"/>
    <title>Big Emacs reference card updated</title>
    <published>2013-04-16T21:02:52Z</published>
    <updated>2013-04-24T16:18:44Z</updated>
    <category term="emacs"/>
    <category term="howto"/>
    <category term="free software"/>
    <content type="html">With the release of Emacs 24.3 last month and the big changes at &lt;a href="http://www.emacswiki.org/emacs/2013-04-24" target="_blank" rel="nofollow"&gt;EmacsWiki&lt;/a&gt;, I've posted an updated version of the &lt;a href="http://www.emacswiki.org/emacs/Reference_Sheet_by_Aaron_Hawley" target="_blank" rel="nofollow"&gt;giant Emacs reference card&lt;/a&gt;.  It now contains new sections on Calendar mode, Ediff and Abbrev mode.  There are also new example commands for keyboard macros, Dired Mode, Occur Mode, table.el and Calc.&lt;br /&gt;&lt;br /&gt;There are now more than 2000 commands up from 1500.  It should also be consistent with the latest version of &lt;a href="http://www.gnu.org/software/emacs/" target="_blank" rel="nofollow"&gt;Emacs&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;It is released under a bunch of free licenses, including version 2 or later of the &lt;a href="http://www.gnu.org/copyleft/gpl.html" target="_blank" rel="nofollow"&gt;GNU GPL&lt;/a&gt; and version 1.2 or later of the &lt;a href="http://www.gnu.org/licenses/fdl.html" target="_blank" rel="nofollow"&gt;GNU FDL&lt;/a&gt;, so people are free to share and modify it.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:30636</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/30636.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=30636"/>
    <title>M-x in Emacs 24.3 is now in Lisp</title>
    <published>2013-03-11T17:26:50Z</published>
    <updated>2013-03-12T14:14:18Z</updated>
    <category term="programming"/>
    <category term="emacs"/>
    <category term="free software"/>
    <content type="html">It didn't make the NEWS file for Emacs 24.3, but Emacs now ships with an `&lt;kbd&gt;M-x&lt;/kbd&gt;' (`&lt;code&gt;execute-extended-command&lt;/code&gt;') that is written in Lisp.  It is no longer written in C.  This should make it easy for users to extend and do new things with this command (execute command name at point, display prefix arguments numerically, ...) by easily redefining it.  Although, it was possible to "advise" the C implementation before given Emacs good advising system with `&lt;code&gt;defadvice&lt;/code&gt;'.&lt;br /&gt;&lt;br /&gt;I had talked about &lt;a href="http://aaronhawley.livejournal.com/26901.html" target="_blank"&gt;Coding Emacs's M-x in Lisp&lt;/a&gt; on this blog over 3 years ago.  It was accepted in Emacs after I finally got around to &lt;a href="http://lists.gnu.org/archive/html/gnu-emacs-sources/2012-03/msg00003.html" target="_blank" rel="nofollow"&gt;posting the code to gnu-emacs-sources&lt;/a&gt; last year.&lt;br /&gt;&lt;br /&gt;Thanks to Stefan Monnier, one of the lead maintainers, for doing most of the leg work of merging these bits into Emacs.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:30252</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/30252.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=30252"/>
    <title>Frobbing pi in Emacs Lisp</title>
    <published>2012-11-27T22:53:09Z</published>
    <updated>2012-11-28T13:29:57Z</updated>
    <category term="programming"/>
    <category term="emacs"/>
    <category term="free software"/>
    <content type="html">&lt;p&gt;What follows is 500 years of technique used to calculate pi --
in Emacs -- up to 1997.  No, Leibniz didn't write Emacs.
However, the Lisp available in Emacs is pretty expressive
although it has limited floating point support (it lacks bignum).
For the traditional mathematical notation, see the article on &lt;a href="http://en.wikipedia.org/wiki/Pi" target="_blank" rel="nofollow"&gt;pi at Wikipedia&lt;/a&gt; which
this article is based on.&lt;/p&gt;

&lt;p&gt;This is 17th century technology for calculating pi in 3 Lisp functions:&lt;/p&gt;

&lt;pre&gt;
(defun pi-Gregory-Leibniz-term (i)
  (/ (* (expt -1 i) 4)
     (1+ (* 2.0 i))))

(defun pi-Gregory-Leibniz-series (n)
  (mapcar (lambda (i) (pi-Gregory-Leibniz-term i))
          (number-sequence 0 n)))

(defun pi-Gregory-Leibniz-sum (n)
  (apply '+ (pi-Gregory-Leibniz-series n)))
&lt;/pre&gt;

&lt;p&gt;After summing 3 million terms (wait for it!) you get the 6th
digit of pi.&lt;/p&gt;

&lt;pre&gt;
(pi-Gregory-Leibniz-sum 2900000)
;=&amp;gt; 3.1415929984172606
&lt;/pre&gt;

&lt;p&gt;The numbers after the 6th decimal digit are incorrect.&lt;/p&gt;

&lt;p&gt;Here's an iterative version of the above defined in a single function:&lt;/p&gt;

&lt;pre&gt;(defun pi-Gregory-Leibniz-sum (n) ;; Now 20% faster!
  (let ((sum 0.0))
    (dotimes (i n)
      (setq sum (+ sum
                   (/ (* (expt -1 i) 4)
                      (1+ (* 2.0 i))))))
    sum))
&lt;/pre&gt;

&lt;p&gt;Using the summed series to calculate pi, discovered at about
the time calculus was invented, was a simplification of previous
formula using infinite products discovered in the 16th
century:&lt;/p&gt;

&lt;pre&gt;(defun pi-Viete (n)
  (let ((prod 1.0)
        (sqrt2 (sqrt 2))
        (sqrt-sum 0))
    (dotimes (i n)
      (setq prod (* prod
                    (sqrt (+ 2 sqrt-sum)))
            sqrt-sum (sqrt (+ 2 sqrt-sum))))
    (/ (expt 2 (1+ n)) prod)))
&lt;/pre&gt;

&lt;p&gt;After 25 iterations, the product series finds the 15th digit.&lt;/p&gt;

&lt;pre&gt;
(pi-Viete 25)
;=&amp;gt; 3.141592653589792
&lt;/pre&gt;

&lt;p&gt;This is early 19th century technology:&lt;/p&gt;

&lt;pre&gt;
(defun pi-Gauss-Legendre (n)
  (let ((a 1.0)
        (b (/ 1 (sqrt 2)))
        (z (/ 1.0 4))
        (p 1.0))
    (dotimes (i n)
      (let* ((a_n+1 (/ (+ a b) 2.0))
             (b_n+1 (sqrt (* a b)))
             (z_n+1 (- z (* p (expt (- a a_n+1) 2))))
             (p_n+1 (* 2 p)))
        (setq a a_n+1
              b b_n+1
              z z_n+1
              p p_n+1)))
    (/ (expt (+ a b) 2)
       (* 4 z))))
&lt;/pre&gt;

&lt;p&gt;In 3 iterations it gets 14 digits of pi.&lt;/p&gt;

&lt;pre&gt;
(pi-Gauss-Legendre 3)
;=&amp;gt; 3.141592653589794
&lt;/pre&gt;

&lt;p&gt;This is 1914 technology (&lt;code&gt;fac&lt;/code&gt; is the factorial function):&lt;/p&gt;

&lt;pre&gt;
(defun pi-Ramanujan (n)
  (let ((sum 0.0))
    (dotimes (k n)
      (let ((4k (* 4 k)))
        (setq sum (+ sum
                     (/ (* (fac 4k) (+ 1103 (* 26390.0 k)))
                        (* (expt (fac k) 4) (expt 396.0 4k))))))
    (/ 9801 (sqrt 2) 2 sum))))
&lt;/pre&gt;

&lt;p&gt;It gets 15 digits in 2 iterations.&lt;/p&gt;

&lt;pre&gt;
(pi-Ramanujan 2)
;=&amp;gt; 3.1415926535897936
&lt;/pre&gt;

&lt;p&gt;This route was found in 1987:&lt;/p&gt;

&lt;pre&gt;
(defun pi-Chudnovsky (n)
  (let ((sum 0.0))
    (dotimes (k n)
      (let ((3k (* 3 k))
            (6k (* 6 k))
            (k! (fac k)))
      (setq sum (+ sum
                   (/ (* (fac 6k) (+ 13591409 (* 545140134.0 k)))
                      (* (fac 3k) (expt k! 3) (expt -640320.0 3k))))))
    (/ (* 426880 (sqrt 10005)) sum)))
&lt;/pre&gt;

&lt;p&gt;It gets 14 digits in 1 iteration.&lt;/p&gt;

&lt;pre&gt;
(pi-Chudnovsky 1)
;=&amp;gt; 3.141592653589734
&lt;/pre&gt;

&lt;p&gt;This is 1995 technology:&lt;/p&gt;

&lt;pre&gt;
(defun pi-Ploufe (n)
  (let ((sum 0))
    (dotimes (i n)
      (let ((8i (* 8 i)))
        (setq sum (+ sum
                     (/ (- (/ 4.0 (+ 8i 1))
                           (/ 2.0 (+ 8i 4))
                           (/ 1.0 (+ 8i 5))
                           (/ 1.0 (+ 8i 6)))
                        (expt 16.0 i))))))
    sum))
&lt;/pre&gt;

&lt;p&gt;It can get 14 digits of pi in 11 iterations.&lt;/p&gt;

&lt;pre&gt;(pi-Ploufe 11)
;=&amp;gt; 3.141592653589793
&lt;/pre&gt;

&lt;p&gt;This is 1997 technology.&lt;/p&gt;

&lt;pre&gt;
(defun pi-Bellard (n)
  (let ((2^2  4.0)
        (2^5  32.0)
        (2^6  64.0)
        (2^8  256.0)
        (2^10 1024.0)
        (sum 0))
    (dotimes (i n)
      (let ((4i (* 4 i))
            (10i (* 10 i)))
        (setq sum (+ sum
                     (*
                      (/ (expt -1 i)
                         (expt 2^10 i))
                      (+ (- (/ 2^5 (1+ 4i)))
                         (- (/ 1.0 (+  4i 3)))
                            (/ 2^8 (+ 10i 1))
                         (- (/ 2^6 (+ 10i 3)))
                         (- (/ 2^2 (+ 10i 5)))
                         (- (/ 2^2 (+ 10i 7)))
                            (/ 1.0 (+ 10i 9))))))))
    (* (/ 1 2^6) sum)))
&lt;/pre&gt;

&lt;p&gt;In 5 iterations it gets 14 digits of precision of pi.&lt;/p&gt;

&lt;pre&gt;(pi-Bellard 5)
;=&amp;gt; 3.1415926535897927
&lt;/pre&gt;

&lt;p&gt;This article is a follow-up to another Lisp math article, &lt;a href="http://aaronhawley.livejournal.com/13104.html" target="_blank"&gt;Frobbing primes with Emacs Lisp&lt;/a&gt;, which -- if you got this far -- you may also enjoy.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:29976</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/29976.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=29976"/>
    <title>Prius saves gas money? (follow-up)</title>
    <published>2012-04-17T12:22:09Z</published>
    <updated>2012-04-17T22:30:56Z</updated>
    <category term="programming"/>
    <category term="emacs"/>
    <category term="ecology"/>
    <content type="html">&lt;p&gt;Toyota makes the Prius -- a popular hybrid car that gets around 50 miles to the gallon (21 km/L, 4.7L/100km).  Presumably, these vehicles save you money at the fuel pump.  However, their sticker price is seemingly high.  One way to check the economic argument is to compare its total cost with a similar but non-hybrid conventional car and see when driving a hybrid starts saving you money.  A convenient and fair comparison is the Corolla also made by Toyota.&lt;/p&gt;

&lt;p&gt;Almost 5 years ago, &lt;a href="http://www.bfccomputing.com/2007/10/29/prius-or-corolla/" target="_blank" rel="nofollow"&gt;Bill McGonigle compared a Prius with a Corolla&lt;/a&gt; and found that only after driving 280613 miles (451603 km) will you start saving money.  &lt;a href="http://aaronhawley.livejournal.com/2790.html" target="_blank"&gt;I confirmed his math with some simple Lisp programming&lt;/a&gt;.  Has this result changed?&lt;/p&gt;

&lt;p&gt;Five years later, the price of gas is up to 4 dollars (US) from 3 dollars but the price point for a Prius is higher.  You still need to drive 229354 (369109 km) miles before you start saving gas money.  That's 60000 miles (96560 km) less than 5 years ago.  Here's the arithmetic in the Emacs Lisp programming language.&lt;/p&gt;

&lt;pre&gt;
(let ((gas-price 4.0)         ;; dollars/gallon
      (prius-price 24000.0)   ;; US dollars
      (corolla-price 16130.0) ;; US dollars
      (prius-mileage 48.0)    ;; miles/gallon
      (corolla-mileage 34.0)) ;; miles/gallon
  (/
   (* prius-mileage corolla-mileage
      (/ (- prius-price corolla-price) gas-price))
   (- prius-mileage corolla-mileage)))
&lt;/pre&gt;

&lt;p&gt;Toyota has introduced a new &lt;em&gt;c model&lt;/em&gt; of the Prius this year.  A smaller-sized version, it is tuned to get better mileage in the city -- better than it does for highway driving.  It's also 15% cheaper than the regular Prius.  If you compared a city-driving Corolla with the Prius c you'd only have to drive 38802 miles (62446 km).  That's pretty good, but is it a fair comparison?  Here's that arithmetic before I answer that question.&lt;/p&gt;

&lt;pre&gt;
(let ((gas-price 4.0)         ;; dollars/gallon
      (priusc-price 18950.0)  ;; US dollars
      (corolla-price 16130.0) ;; US dollars
      (priusc-mileage 53.0)   ;; miles/gallon
      (corolla-mileage 27.0)) ;; miles/gallon
  (/
   (* priusc-mileage corolla-mileage
      (/ (- priusc-price corolla-price) gas-price))
   (- priusc-mileage corolla-mileage)))
&lt;/pre&gt;

&lt;p&gt;Average drivers don't earn 15000 miles (24140 km) a year in the city.  Most of those miles are at a highway's pace.  Further, the smaller Prius c is more comparable to the Toyota Yaris than a Corolla.  Comparing the lower sticker price and highway mileage of a Yaris with the Prius c driven on the highway requires driving 264112 miles (425047 km).  Here's the arithmetic.&lt;/p&gt;

&lt;pre&gt;
(let ((gas-price 4.0)         ;; dollars/gallon
      (priusc-price 18950.0)  ;; US dollars
      (yaris-price 14115.0)   ;; US dollars
      (priusc-mileage 46.0)   ;; miles/gallon
      (yaris-mileage 38.0))   ;; miles/gallon
  (/
   (* priusc-mileage yaris-mileage
      (/ (- priusc-price yaris-price) gas-price))
   (- priusc-mileage yaris-mileage)))
&lt;/pre&gt;

&lt;p&gt;After 5 years, the hybrid car still isn't economical unless a typical owner drives one for 15 years.  According to Consumer Reports, &lt;a href="http://news.consumerreports.org/cars/2011/02/200000-mile-toyota-prius-still-performs.html" target="_blank" rel="nofollow"&gt;Toyota's reputation for reliability is extending to the Prius&lt;/a&gt;, where a Prius is able to maintain its efficiency and the batteries have held up after 10 years.  However, the average Prius owner probably doesn't hold on to the car this long.&lt;/p&gt;

&lt;p&gt;More likely, consumers purchase hybrid vehicles because of their reduced environmental impact.  It's &lt;a href="http://science.howstuffworks.com/science-vs-myth/everyday-myths/does-hybrid-car-production-waste-offset-hybrid-benefits1.htm" target="_blank" rel="nofollow"&gt;estimated that just producing a car can be 10 to 20% of a vehicle's lifetime emissions&lt;/a&gt;.  Presumably, the energy to make a Prius is greater than a conventional car since it has two engines (combustion and electrical) and additional battery.  However, Toyota doesn't release the estimated emissions from manufacturing a Prius.&lt;/p&gt;

&lt;p&gt;The city-optimized Prius c is a triple threat in metropolitan areas for its lower price, better efficiency and reduce impact on smog.  However, these places typically have mass transit.  The best way to save money is commute by walking, biking, car pooling or taking the bus or train.  These options are better for the environment as well.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:29617</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/29617.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=29617"/>
    <title>Spring cleaning</title>
    <published>2012-01-05T17:09:38Z</published>
    <updated>2012-01-05T17:11:09Z</updated>
    <category term="economy"/>
    <content type="html">&lt;p&gt;After 50 years as an academic economist, spending it deconstructing the neo-classical economics of Alfred Marshall and his "Cambridge School" -- of which she was a member early in her career -- and producing work deserving of a Nobel Prize, Joan Robinson would instead see the system resurrected in the US -- notably by the "Chicago School" of Milton Friedman and Fred Hayek.  In 1980, she commented on the poverty of orthodox economics and sketched a solution.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;&lt;q&gt;After the Second World War, the baton of leadership in teaching economics, along with leadership in the capitalist world, passed to the USA.  Instead of meeting the challenge of the Keynesian revolution head on, the profession in the USA split the subject into two parts, macro and micro.  In the macro section it was permissible to contemplate fluctuations in employment and even to hint at remedies for a deficiency in effective demand, while micro theory returned to the analysis of equilibrium established by the free play of market forces.  Keynesian ideas were allowed a certain sphere of operation while the central doctrine was safely walled off from them.[...]&lt;/q&gt;&lt;/p&gt;

&lt;p&gt;&lt;q&gt;The whole subject [of inequality] is so embarrassing that in fact it is scarcely mentioned.  There is no treatment at all of the determination of the distribution of income in orthodox teaching, and precious little about its consequences.  What to the general public appears one of the most interesting of all questions in economics is simply left out of the syllabus.&lt;/q&gt;&lt;/p&gt;

&lt;p&gt;&lt;q&gt;In its general influence on educated public opinion, orthodox teaching has been not merely feeble and confused but positively pernicious.  It gives support to the view that expenditure by a government that is beneficial to the inhabitants of its territory is 'socialism' and must be prevented at all costs.  This reconciles an otherwise more or less sane and benevolent public opinion to the arms race which seems to be dragging us all to destruction.  But that is another story.&lt;/q&gt;&lt;/p&gt;

&lt;p&gt;&lt;q&gt;It seems to me that the whole complex of theories and models in the textbooks is in need of a thorough spring cleaning.  We should throw out all self-contradictory propositions, unmeasurable quantities and indefinable concepts and reconstruct a logical basis for analysis with what, if anything, remains.&lt;/q&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;From the essay "The theory of normal prices and reconstruction of economic theory" published in &lt;cite&gt;Issues in contemporary macroeconomics and distribution&lt;/cite&gt; edited by George R. Feiwel.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:29311</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/29311.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=29311"/>
    <title>Emacs custom global key bindings</title>
    <published>2011-12-13T18:25:58Z</published>
    <updated>2011-12-16T13:38:46Z</updated>
    <category term="emacs"/>
    <category term="howto"/>
    <category term="free software"/>
    <content type="html">&lt;p&gt;The only place reserved for users to put custom global key bindings in Emacs is &lt;kbd&gt;`C-c LETTER'&lt;/kbd&gt;.  (Obviously, all Emacs key bindings can be changed at ones own peril and people often do.)  Here's some examples.&lt;/p&gt;

&lt;pre&gt;
(global-set-key (kbd "C-c r") 'query-replace-regexp)
(global-set-key (kbd "C-c i") 'insert-buffer)
(global-set-key (kbd "C-c w") 'write-region)
&lt;/pre&gt;

&lt;p&gt;I also used to like having short aliases for &lt;kbd&gt;`M-x'&lt;/kbd&gt;.  Here's some popular ones used for working with Emacs Lisp.&lt;/p&gt;

&lt;pre&gt;
(defalias 'tdoe 'toggle-debug-on-error)
(defalias 'eval- 'eval-region) ;; M-x eval
(defalias 'load- 'load-file) ;; M-x load
(defalias 'ff 'find-function)
(defalias 'fv 'find-variable)
(defalias 'fl 'find-library)
(defalias 'll 'load-library)
&lt;/pre&gt;

&lt;p&gt;I've come across the strategy of using &lt;kbd&gt;`C-c'&lt;/kbd&gt; and short words or phrases for key bindings rather than single keys.&lt;/p&gt;

&lt;pre&gt;
(global-set-key (kbd "C-c now")
                (lambda ()
                  "Insert current universal time."
                  (interactive "*")
                  (insert
                   (format-time-string "%Y-%m-%d %H:%M UTC"
                                       (current-time) 'universal))))

(global-set-key (kbd "C-c file") 
                (lambda (file &amp;optional args)
                  "Insert name of FILE into buffer after point."
                  (interactive "*fInsert file name: \nP")
                  (cond ((eq '- args)
                         (insert (file-relative-name file)))
                        ((not (null args))
                         (insert (expand-file-name file)))
                        (t
                         (insert file)))))

(global-set-key (kbd "C-c fill") 'fill-region)
(global-set-key (kbd "C-c delete") 'delete-region)
(global-set-key (kbd "C-c svn") 'svn-status)
(global-set-key (kbd "C-c git") 'magit-status)
(global-set-key (kbd "C-c compile") 'compile)
;; Same as M-x recompile
(global-set-key (kbd "C-c recompile") 'recompile) 

(global-set-key (kbd "C-c copy SPC line") ;; Repeat with `C-x z'
                (lambda ()
                  (interactive)
                  (forward-line 1)
                  (open-line 1)
                  (copy-from-above-command))) ;; From misc.el
;; Same as M-x copy above RET
(global-set-key "\C-ccopy above" 'copy-from-above-command)
&lt;/pre&gt;

&lt;p&gt;For the seeing Emacs user, display the keys you've pressed earlier by modifying this variable to something closer to the speed of the human eye.  By default, Emacs only shows the keys you've entered in the echo area after every one second.&lt;/p&gt;

&lt;pre&gt;
(setq echo-keystrokes 0.02)
&lt;/pre&gt;


&lt;p&gt;It's nice how Emacs automatically creates prefix key maps for these long key sequences.  For instance, &lt;kbd&gt;`C-c compile'&lt;/kbd&gt; and &lt;kbd&gt;`C-c copy line'&lt;/kbd&gt; share the &lt;kbd&gt;`C-c c'&lt;/kbd&gt; and &lt;kbd&gt;`C-c co'&lt;/kbd&gt; prefixes. However, there is no way to use both single key bindings and the new longer ones simultaneously should they share letters.  When they conflict, the shorter will get stomped by the longer version. For example, the previous single key binding for &lt;kbd&gt;`C-c r'&lt;/kbd&gt; will not work since it gets shadowed by &lt;kbd&gt;`C-c recompile'&lt;/kbd&gt;.&lt;/p&gt;

&lt;p&gt;I'm using a mix of both short and long key bindings since there are some editing commands that I need to keep on a short key binding but some less frequently used commands on single key bindings that I couldn't remember easily.  Although, it is a delicate dance of picking useful short phrases that don't conflict with single key bindings and vice versa.  I'm not planning to get carried away with it all.  I'm a &lt;a href="http://aaronhawley.livejournal.com/28413.html" target="_blank"&gt;satisfied user of M-x&lt;/a&gt;.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:29138</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/29138.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=29138"/>
    <title>World War Two Veteran Quote</title>
    <published>2011-11-11T16:50:13Z</published>
    <updated>2011-11-11T16:50:37Z</updated>
    <content type="html">&lt;blockquote&gt;&lt;q&gt;I don’t think there’s ever been a good war, never been one.  It’s the height of ignorance.  I mean, it’s legalized murder.  You’re killing somebody and then your mother teaches you to believe in God and then, at 17, they say now we’re gonna show you how to kill.  It’s too schizophrenic.  It doesn’t make sense.  We should believe in God, believe in being a human being, and giving to the earth instead of taking from it.&lt;/q&gt; -- Anthony Dominick Benedetto
&lt;/blockquote&gt;

&lt;p&gt;Tony Bennett recently received criticism for making the obvious point about a so-called war on terrorism, "But who are the terrorists? Are we the terrorists or are they the terrorists? Two wrongs don’t make a right."&lt;/p&gt;

&lt;p&gt;Tony Bennett served in the the US Army and a tour in the final year of the second World War that began in France and ended in Germany.  He saw the Battle of the Bulge, spent winter months in a foxhole, engaged in town-to-town fighting and liberated one of the German concentration camps at Dachau.&lt;/p&gt;

&lt;p&gt;It's said that freedoms in the US were and are fought for in wars here and abroad.  If you fight in a war don't you get the right to speak freely?  It was a corollary that never existed. It was invented.&lt;/p&gt;

&lt;p&gt;Studies have shown that recent veterans are facing unemployment at twice the US average.  Returning veterans represent nearly 1/5 of all suicides.  More recently, Dover Air Force Base has been found to be mishandling the remains of soldiers returning from US occupations and interventions.&lt;/p&gt;

&lt;p&gt;I do not participate in the genuflection and formal observance of Veteran's Day, but will support the rights and respect of veterans every day of the year.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:28618</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/28618.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=28618"/>
    <title>Update to big Emacs reference card</title>
    <published>2011-08-10T13:58:48Z</published>
    <updated>2013-04-16T21:02:16Z</updated>
    <category term="emacs"/>
    <content type="html">For the first time in over 2 years, I finally got around to updating my &lt;a href="http://www.emacswiki.org/emacs/Reference_Sheet_by_Aaron_Hawley" target="_blank" rel="nofollow"&gt;giant Emacs reference card&lt;/a&gt;.  There are now more than 1500 commands up from 1000.  It should also be consistent with the latest version of &lt;a href="http://www.gnu.org/software/emacs/" target="_blank" rel="nofollow"&gt;Emacs&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I transform the Wiki markup from a simple text markup using some "quick and dirty" Emacs Lisp.  Besides being easier to work on than Wiki markup, the source format is also printable.  The HTML version is almost 60 pages.  Using &lt;a href="http://www.gnu.org/software/a2ps/" target="_blank" rel="nofollow"&gt;a2ps&lt;/a&gt; on the text format it prints on 15 pieces of paper.&lt;br /&gt;&lt;br /&gt;It's a lot of work, but it's a good way for me to learn more about Emacs.  Hopefully, others will find it useful, too.  I suggest printing only a few sections that you would like to improve on.&lt;br /&gt;&lt;br /&gt;Since it is released under a bunch of free licenses, including version 2 or later of the &lt;a href="http://www.gnu.org/copyleft/gpl.html" target="_blank" rel="nofollow"&gt;GNU GPL&lt;/a&gt; and version 1.2 or later of the &lt;a href="http://www.gnu.org/licenses/fdl.html" target="_blank" rel="nofollow"&gt;GNU FDL&lt;/a&gt;, people are free to share and modify it.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:28413</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/28413.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=28413"/>
    <title>Learning Emacs key bindings</title>
    <published>2011-07-13T19:15:58Z</published>
    <updated>2011-07-13T19:15:58Z</updated>
    <category term="emacs"/>
    <category term="howto"/>
    <category term="free software"/>
    <content type="html">&lt;p&gt;Emacs key bindings are intimidating at first since they are quite distinct from those used in other applications and platforms.  The following is based on discussion on the Emacs IRC channel and is posted to the &lt;a href="http://www.emacswiki.org/emacs/LearningEmacs" target="_blank" rel="nofollow"&gt;Emacs Wiki&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After studying the tutorial that comes with Emacs, most people learn best by doing and not just by reading over a list of commands and trying to memorize them. Get yourself a text file to play around with. Make a backup copy if you're nervous about losing it. But don't worry -- Emacs makes it hard to lose your work, and it has a great undo command: `&lt;kbd&gt;C-/&lt;/kbd&gt;' or `&lt;kbd&gt;C-_&lt;/kbd&gt;'.&lt;/p&gt;

&lt;p&gt;Keep the following advice in mind.&lt;/p&gt;

&lt;ol&gt;
 &lt;li&gt;Try to memorize the most commonly used commands in the tutorial.
 &lt;li&gt;Use Apropos or help to find commands to accomplish a task.
 &lt;li&gt;Run the command for a task with `&lt;kbd&gt;M-x&lt;/kbd&gt;' and typing it in.
 &lt;li&gt;Run the command again by using `&lt;kbd&gt;M-x M-p&lt;/kbd&gt;' or by typing it in again.
 &lt;li&gt;On the third time, see if the command is bound to a key binding with `&lt;kbd&gt;C-h w&lt;/kbd&gt;'.
 &lt;li&gt;If you forget a key binding (sometimes you forget even the basic commands introduced in the tutorial), try `&lt;kbd&gt;C-h w M-p&lt;/kbd&gt;' to peek at it again or use `&lt;kbd&gt;C-h b&lt;/kbd&gt;' to browse the available bindings.
 &lt;li&gt;If you can't burn a key binding in to your brain with this approach, then you're not using it enough and it doesn't deserve a key binding.
 &lt;li&gt;If a key binding is atrocious, only then bind the command to an unused key.
&lt;/ol&gt;

&lt;p&gt;Some beginners rush too quickly and add or change key bindings. This avoids learning Emacs and risks spending more time configuring. Competency with `&lt;kbd&gt;M-x&lt;/kbd&gt;' and help are actually core Emacs skills for life. `&lt;kbd&gt;M-x&lt;/kbd&gt;' should become your command line in Emacs.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:27978</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/27978.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=27978"/>
    <title>Executive Director, GNOME Foundation </title>
    <published>2011-06-21T18:05:29Z</published>
    <updated>2011-06-21T18:05:29Z</updated>
    <category term="free software"/>
    <content type="html">It was announced today that &lt;a href="http://www.gnome.org/press/2011/06/karen-sandler-named-new-executive-director-of-the-gnome-foundation/" target="_blank" rel="nofollow"&gt;Karen Sandler was named new Executive Director of the GNOME Foundation&lt;/a&gt;.  I don't know Karen, nor am I currently a stock holder of Karen Sandler or the GNOME foundation, but she is a co-host of the &lt;a href="http://www.faif.us/" target="_blank" rel="nofollow"&gt;Free as in Freedom oggcast&lt;/a&gt; of which I'm a dedicated listener.&lt;br /&gt;&lt;br /&gt;Given her years as general counsel at the &lt;a href="http://www.softwarefreedom.org/" target="_blank" rel="nofollow"&gt;Software Freedom Law Center&lt;/a&gt; (SFLC) and the usual legal experience appointing a lawyer to a board gives, Karen is also a good appointment for her non-law insights on free software development by building organizations that sustain and protect the free software ecosystem.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:27271</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/27271.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=27271"/>
    <title>Refusing to learn</title>
    <published>2009-09-24T06:39:48Z</published>
    <updated>2011-02-21T02:30:48Z</updated>
    <category term="programming"/>
    <category term="emacs"/>
    <category term="software"/>
    <content type="html">An essay called &lt;a href="http://dept-info.labri.u-bordeaux.fr/~strandh/Essays/psychology.html" target="_blank" rel="nofollow"&gt;The psychology of learning&lt;/a&gt; from 2003 by &lt;a href="http://dept-info.labri.u-bordeaux.fr/~strandh/index.en.html" target="_blank" rel="nofollow"&gt;Robert Strandh&lt;/a&gt;, director of the D&amp;eacute;partement d'Informatique at Universit&amp;eacute; Bordeaux, France, describes a trend in computing where close-mindedness (my phrase) risks opportunities for learning &lt;em&gt;and&lt;/em&gt; effectiveness.&lt;br /&gt;&lt;br /&gt;The bad-mouthing of competing technologies by adherents of another technology is well known.&amp;nbsp; The practice goes back to early days of hacker culture when arguments would abound in choice of programming languages (or assembly), mainframe manufacturer or model (consider also &amp;quot;PC&amp;nbsp;versus Mac&amp;quot; over the last two recent decades).&amp;nbsp; These divisions can partition customers, industries and educators into islands with different customs and ideas.&amp;nbsp; Strandh doesn't visit this in the essay.&amp;nbsp; No, according to Strandh, opinions like these arise in young students in more subtle but still worrisome ways.&lt;br /&gt;&lt;blockquote&gt;[...] I have often observed that students are very inefficient in their work.  They frequently use methods of working that are unproductive and slow.  Some examples:&lt;ul&gt;&lt;li&gt;&lt;div&gt;Students do not know how to touch-type.  Instead of taking the        relatively limited time to learn to do it, they waste many hours per week on slow typing and typing errors.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;Students frequently do not know how to use advanced features in        the text editor such as the interface to the version-control        system, the interface to the Lisp system, etc.  Again instead        of taking a short time to learn, they waste much more time.&lt;/li&gt;&lt;li&gt;Students do not know how to use a debugger.  Instead, they        waste time debugging programs with trace output. [...]&lt;/li&gt;&lt;/ul&gt;&lt;/blockquote&gt;Strandh suggests this could simply be &amp;quot;reluctance to learning new tools and methods&amp;quot;, but can also become &amp;quot;a kind of reaction orders of magnitude stronger&amp;quot;.  He attributes the reaction to &amp;quot;a need to achieve performance &lt;em&gt;immediately&lt;/em&gt;&amp;quot; (original emphasis).  Continuing:&lt;br /&gt;&lt;blockquote&gt;Such performance leaves no time for intellectual curiosity.  Instead, techniques already known to them must be applied to solve problems.  To these people, failure is a disaster whose sole feature is to harm instant performance.  Similarly, learning represents the possibility of failure and must thus be avoided if possible.  To the people in this category, knowledge in other people also represents a threat. As long as everybody around them use tools, techniques, and methods that they themselves know, they can count on outperforming these other people.  But when the people around them start learning different, perhaps better, ways, they must defend themselves. [...]&lt;/blockquote&gt;Strandh attributes these behaviors to a description given to him personally by Boston College psychology professor, &lt;a href="http://www2.bc.edu/~barretli/" target="_blank" rel="nofollow"&gt;Lisa Feldman Barrett&lt;/a&gt;, who in turn cites the work of well-known psychologist &lt;a href="http://en.wikipedia.org/wiki/Carol_Dweck" target="_blank" rel="nofollow"&gt;Carol Dweck&lt;/a&gt;. The research which posits a duality of &lt;dfn&gt;perfection-oriented&lt;/dfn&gt; and &lt;dfn&gt;performance-oriented&lt;/dfn&gt; is worth looking into as an explanation.&lt;br /&gt;&lt;br /&gt;The best part of the essay are not about the psychology theory, but his personal anecdotes on computing inspired by the psychology researcher's works.&lt;br /&gt;&lt;blockquote&gt;[...] I talked to a student of computer science who told me why a particular programming language was bad.  In fact he told me it was so bad that he had moved to a different university in order to avoid courses that used that particular language.  When asked, he admitted he had never written a single program in that language.  He simply did not know what he was talking about.  And he was willing to fight for it. [...]&lt;br /&gt;&lt;br /&gt;[...] I have seen professors in mathematics who were obviously perfection-oriented with respect to mathematics, be firmly in the performance-oriented category with respect to the efficient use of (say) word processors.  It is almost a surrealistic experience to see a person in one situation full of intellectual curiosity and wanting to know everything about everything, and in another situation argue why you should not use a particular method that he himself does not know anything about, for reasons that are obviously totally artificial. [...]&lt;br /&gt;&lt;br /&gt;[...] I have observed that people ignorant in a particular domain, or not knowing a particular tool or technique, would go to great trouble to explain why knowing this domain, tool, or technique, would be a complete waste of time. Usually these explanations were based on erroneous ideas of what it represented.  To make things worse, they were perfectly willing to present their erroneous arguments to the very experts in the field in question. [...]&lt;br /&gt;&lt;/blockquote&gt;In this anecode, Strandh likely admits his membership in the Church of Emacs.&lt;br /&gt;&lt;blockquote&gt;[...]  I have heard people argue against a tool that they ignore based on the fact that it can do &lt;em&gt;too much&lt;/em&gt;.  Too much functionality in a tools is a problem only if unneeded or unwanted functionality somehow makes it harder to use the needed and wanted parts.  I have heard people argue about the amount of memory a particular tool requires, whereas the additional memory required might represent a cost equivalent to a few hours of work at most.  A favorite idea is to label a particular tool with a name suggesting what it ought to be doing, and then arguing that it is doing &lt;em&gt;more&lt;/em&gt; than that.  For instance, a text editor that is capable of automatic indentation would be accused of being a &amp;quot;kitchen-sink&amp;quot; tool because after all it does much more than allowing the user to just edit text. (original emphasis) [...]&lt;br /&gt;&lt;/blockquote&gt;Strandh ends by revealing his own transgressions of this same type.&lt;br /&gt;&lt;blockquote&gt;[...] I myself recently discovered a marvelous feature in a programming language that I had purposely avoided for the past 10 years, simply because 10 years ago, a colleague (who did not know the feature) explained to me that it was no good.  We were both victims of our own minds.  My colleague because he obviously needed to defend that he had made a different choice, and myself because I subconsciously found it very appealing to be able to brush off the feature as useless and thus not having to learn it.  It is hard to overestimate the wasted time I have put in during the past 10 years due to considerably lower productivity than I could have had, had I realized at the time what I now know about human psychology. [...]&lt;/blockquote&gt;I would add another possible explanation for these reactions is another one rooted in &amp;quot;human psychology&amp;quot;:&amp;nbsp; It is a &lt;a href="http://en.wikipedia.org/wiki/Defence_mechanism" target="_blank" rel="nofollow"&gt;defense mechanism&lt;/a&gt;.&amp;nbsp; Computing possesses a great diversity and many ways to do things.&amp;nbsp; Barring a few mighty monopolies in hardware and software, there still exists much complexity and specialization in the field of computing.&amp;nbsp; As regressive overt opinions are, the instinct may be a method for people to manage and focus on their work.&amp;nbsp; This would especially be the case for budding students.&amp;nbsp; Avoiding potentially labor-saving tools and knowledge in the rush to finish a task is unfortunate, but investigating alternatives has to be limited or else a task is never started.&amp;nbsp; It's like the lumberjack (or jill) in the metaphor who sharpens their saw or axe but never cut the tree down since they never got around to swinging the axe.&lt;br /&gt;&lt;br /&gt;Despite my sympathy, people who let this close-minded instinct take over and influence themselves and others is indefensible.&amp;nbsp; People should simply answer &amp;quot;I don't know&amp;quot; rather than than making &amp;quot;complete fools of themselves&amp;quot; by expressing what are only hunches.&amp;nbsp; A couple famous quotes about &amp;quot;ignorance&amp;quot; and &amp;quot;fear&amp;quot; are probably worth inserting here.&amp;nbsp; I'll leave it as an exercise.&amp;nbsp; The point is stop being cavalier and just admit you don't know rather than trying to prove knowing everything.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:25343</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/25343.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=25343"/>
    <title>Iran is not a twitter revolution</title>
    <published>2009-06-29T21:26:19Z</published>
    <updated>2009-06-29T21:27:50Z</updated>
    <content type="html">&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Reese_Erlich" target="_blank" rel="nofollow"&gt;Reese Erlich&lt;/a&gt; is a freelance journalist and author who's been covering recent events in Iran -- *from Iran* and not just his computer chair like many in the mainstream media have.&lt;/p&gt;

&lt;p&gt;He recently countered "left-wing Doubting Thomas arguments" in an &lt;a href="http://www.commondreams.org/view/2009/06/28-10" target="_blank" rel="nofollow"&gt;article on Common Dreams .org&lt;/a&gt;.  In his arguments, I found these observations about Iranians "fighting for political, social and economic justice" inspiring.&lt;/p&gt;

&lt;blockquote&gt;

&lt;p&gt;[...]&lt;/p&gt;

&lt;p&gt;Assertion: The U.S. has a long history of meddling in Iran, so it must be behind the current unrest. &lt;/p&gt;

&lt;p&gt;[...]&lt;/p&gt;

&lt;p&gt;Frankly, based on my observations, no one was leading the demonstrations. During the course of the week after the elections, the mass movement evolved from one protesting vote fraud into one calling for much broader freedoms. You could see it in the changing composition of the marches. There were not only upper middle class kids in tight jeans and designer sun glasses. There were growing numbers of workers and women in very conservative chadors.&lt;/p&gt;

&lt;p&gt;Iranian youth particularly resented President Ahmadinejad's support for religious militia attacks on unmarried young men and women walking together and against women not covering enough hair with their hijab. Workers resented the 24 percent annual inflation that robbed them of real wage increases. Independent trade unionists were fighting for decent wages and for the right to organize.&lt;/p&gt;

&lt;p&gt;Some demonstrators wanted a more moderate Islamic government. Others advocated a separation of mosque and state, and a return to parliamentary democracy they had before the 1953 coup. But virtually everyone believes that Iran has the right to develop nuclear power, including enriching uranium. Iranians support the Palestinians in their fight against Israeli occupation, and they want to see the U.S. get out of Iraq.&lt;/p&gt;

&lt;p&gt;So if the [sic] CIA was manipulating the demonstrators, it was doing a piss poor job.&lt;/p&gt;

&lt;p&gt;[...]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;See also Erlich's &lt;a href="http://blogs.reuters.com/great-debate/author/reeseerlich/" target="_blank" rel="nofollow"&gt;Iran is not a twitter revolution&lt;/a&gt;.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:24759</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/24759.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=24759"/>
    <title>Drivable Motor Vehicle Act</title>
    <published>2009-06-24T20:25:06Z</published>
    <updated>2009-06-24T21:27:39Z</updated>
    <category term="free software"/>
    <content type="html">I noticed an &lt;a href="http://drupal.geek.nz/blog/richard-stallman-free-software-christchurch#comment-375" target="_blank" rel="nofollow"&gt;old comment posted to someone's site&lt;/a&gt; by &lt;span  class="ljuser  i-ljuser  i-ljuser-type-Y     "  data-ljuser="mjd_blog" lj:user="mjd_blog" &gt;&lt;a href="https://mjd-blog.livejournal.com/profile/"  target="_self"  class="i-ljuser-profile" &gt;&lt;img  class="i-ljuser-userhead"  src="https://l-stat.livejournal.net/img/syndicated.png?v=6283&amp;v=912" /&gt;&lt;/a&gt;&lt;a href="https://mjd-blog.livejournal.com/" class="i-ljuser-username"   target="_self"   &gt;&lt;b&gt;Matthew Davidson&lt;/b&gt;&lt;/a&gt;&lt;/span&gt; who wrote a car metaphor for free software.  This is a commonly used metaphor device, but I think it's especially good.  (I *swear* I didn't find this in a search for my own surname).&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;I drive a little Toyota hatchback. I do so because I got it relatively cheap from my sister-in-law. This was possible because she owned the car, [instead of having] a non-transferable license to use the car under certain conditions.&lt;br /&gt;&lt;br /&gt;I know how to pump up the tyres and refill the thing that squirts water on the windscreen. That's all I know about maintaining the vehicle, and probably all I ever will know. I take it to the local mechanic of my choice every couple of years and he fustigates the Smoot-Hawley flanges or whatever for me, at what I can only assume is a reasonable price.&lt;br /&gt;&lt;br /&gt;I am very glad that the bonnet was not locked shut at the factory by Toyota, and that there is not a Drivable Motor Vehicle Act (DMVA) to make it a criminal offense for anybody to attempt to service their own car, or pay somebody other than the manufacturer to service it. I may not personally know the first thing about its [sic] inner workings, but if I suspect I'm being charged to much for some work on my car, I can go a few hundred metres up the road to the next mechanic who can provide me with a quote.&lt;br /&gt;&lt;br /&gt;Most of these mechanics probably chose this trade after opening up the bonnet of their own car and having a playful poke around, the same way I learned how to program computers. Now as Richard Stallman would say, the ethical issues around car manufacturing and software manufacturing are not the same; I don't have the legal right to make a perfect copy of my car, but that's okay because I don't have the practical means to do so -- no matter how much technical skill I am able to acquire, and neither does anybody but very large corporations, so losing that freedom (through patents) doesn't cost me anything, while potentially delivering the benefits to society that the patent system [for car manufacturing] is supposed to provide.&lt;br /&gt;&lt;br /&gt;But if somebody paid me to write some software for them and I said "okay, I'll write it for you, but only under the condition that you don't copy it or attempt to fix or improve it yourself, or pay somebody else to fix or improve it," that would be a very bad deal for the customer, because the means to do these things are so cheap that you are practically only paying for the time of the person who does the work (or not, if you do it yourself). It would be such a bad deal in fact, that if I managed to convince a sucker to fall for it, I would have to regard my own behaviour as unethical.&lt;br /&gt;&lt;br /&gt;Granted there aren't as many programmers as motor vehicle mechanics in my town, but that can and should change. Already I can point to half a dozen people I know who could (and hopefully will) become as familiar with the inner workings of [the free software package] Drupal as myself with only a little effort. As this begins to happen across a wide range of software the real cost of proprietary software (as opposed to the mere price tag), and the benefits of freedom, will become apparent to even the most non-technical users.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Speaking of "tryes", "metres" and "bonnets"; the &lt;a href="http://www.endsoftpatents.org/" target="_blank" rel="nofollow"&gt;end software patents campaign&lt;/a&gt; needs help documenting the patent issue in &lt;a href="http://en.swpat.org/wiki/Australia" target="_blank" rel="nofollow"&gt;Australia&lt;/a&gt; and &lt;a href="http://en.swpat.org/wiki/New_Zealand" target="_blank" rel="nofollow"&gt;New Zealand&lt;/a&gt;, among other locales.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:24499</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/24499.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=24499"/>
    <title>Release of dump package</title>
    <published>2009-06-18T18:05:14Z</published>
    <updated>2009-06-18T18:05:14Z</updated>
    <category term="unix"/>
    <category term="free software"/>
    <content type="html">The &lt;a href="http://dump.sourceforge.net/" target="_blank" rel="nofollow"&gt;dump/restore package&lt;/a&gt; version 0.4b42 is being released today.  It is the first release in over 3 years.  &lt;a href="http://sourceforge.net/project/shownotes.php?group_id=1306&amp;amp;release_id=690716" target="_blank" rel="nofollow"&gt;Read the release notes&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;It supports versions two through four of the Linux kernel's extended file system (ext2, ext3, ext4).  Technically, it is considered beta software, but I have reason to believe there are a lot of people who use it in production systems.  You can also use it for disk-based backups.  You don't need to have a &lt;a href="http://en.wikipedia.org/wiki/Tape_jukebox" target="_blank" rel="nofollow"&gt;tape jukebox&lt;/a&gt; to use it, although it is designed for use with tape backups.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:24262</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/24262.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=24262"/>
    <title>Sorting UTF-8 strings in PHP</title>
    <published>2009-05-28T19:39:53Z</published>
    <updated>2009-05-28T19:42:18Z</updated>
    <category term="programming"/>
    <category term="php"/>
    <category term="howto"/>
    <content type="html">&lt;p&gt;With Unicode characters, in this case the popular UTF-8, sometimes you need to convert characters to ASCII to get things done in PHP.  In the case of sorting Unicode, there are the existing solutions of &lt;a href="http://php.net/collator.sort" target="_blank" rel="nofollow"&gt;collator_sort()&lt;/a&gt; for PHP5 and &lt;a href="http://php.net/strcoll" target="_blank" rel="nofollow"&gt;strcoll()&lt;/a&gt; since PHP4.  However, they both assume a locale.  A hack that is locale-agnostic would just "normalize" Unicode characters to ASCII.&lt;/p&gt;

&lt;p&gt;This is far from complete, but seems to do the right thing.&lt;/p&gt;

&lt;pre&gt;
    &lt;span style="color: #da70d6;"&gt;&amp;lt;?php&lt;/span&gt;

    &lt;span style="color: #b22222;"&gt;/**&lt;/span&gt;&lt;span style="color: #b22222;"&gt;
     * Normalize international characters for purposes like sorting and
     * searching by using a heuristic that just uses ASCII--the english
     * alphabet ordering--for a multilingual solution--no locale setting.
     &lt;/span&gt;&lt;span style="color: #b22222;"&gt;*/&lt;/span&gt;
    &lt;span style="color: #000000; background-color: #ffffff;"&gt;header(&lt;/span&gt;&lt;span style="color: #bc8f8f;"&gt;"Content-type: text/plain; charset=utf-8"&lt;/span&gt;);

    &lt;span style="color: #b22222;"&gt;/**&lt;/span&gt;&lt;span style="color: #b22222;"&gt;
     * I&amp;#241;t&amp;#235;rn&amp;#226;ti&amp;#244;n&amp;#224;liz&amp;#230;ti&amp;#248;n
     *
     * Example from Sam Ruby
     * http://intertwingly.net/stories/2004/04/14/i18n.html
     * 
     * By way of WACT team
     * http://www.phpwact.org/php/i18n/charsets
     &lt;/span&gt;&lt;span style="color: #b22222;"&gt;*/&lt;/span&gt;
    $&lt;span style="color: #b8860b;"&gt;internationalization&lt;/span&gt; = &lt;span style="color: #000000; background-color: #ffffff;"&gt;array(&lt;/span&gt;
				  &lt;span style="color: #bc8f8f;"&gt;"I"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;I
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB1"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#241;
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"t"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;t
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"\xC3\xAB"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#235;
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"r"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;r
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"n"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;n
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA2"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#226;
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"t"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;t
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"i"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;i
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB4"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#244;
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"n"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;n
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA0"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#224;
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"l"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;l
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"i"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;i
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"z"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;z
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA6"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#230;
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"t"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;t
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"i"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;i
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB8"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#248;
    &lt;/span&gt;                              &lt;span style="color: #bc8f8f;"&gt;"n"&lt;/span&gt;); &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;n
    &lt;/span&gt;
    &lt;span style="color: #b22222;"&gt;/** &lt;/span&gt;&lt;span style="color: #b22222;"&gt;
     * Use strtr() with this dictionary to convert to ASCII.
     * This data structure is not comprehensive.
     &lt;/span&gt;&lt;span style="color: #b22222;"&gt;*/&lt;/span&gt;
    $&lt;span style="color: #b8860b;"&gt;utf8_dict&lt;/span&gt; = &lt;span style="color: #000000; background-color: #ffffff;"&gt;array(&lt;/span&gt;&lt;span style="color: #bc8f8f;"&gt;"\xC3\x80"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"A"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#192;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x81"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"A"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#193;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x82"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"A"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#194;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x83"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"A"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#195;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x84"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"A"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#196;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x85"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"A"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#197;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x86"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"A"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#198;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x9E"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"B"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#222;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x87"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"C"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#199;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC4\x86"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"C"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#262;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC4\x8C"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"C"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#268;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC4\x90"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"Dj"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#272;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x88"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"E"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#200;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x89"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"E"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#201;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x8A"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"E"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#202;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x8B"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"E"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#203;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC4\x9E"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"G"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#286;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x8C"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"I"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#204;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x8D"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"I"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#205;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x8E"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"I"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#206;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x8F"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"I"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#207;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC4\xB0"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"I"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#304;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x91"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"N"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#209;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x92"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"O"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#210;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x93"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"O"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#211;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x94"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"O"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#212;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x95"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"O"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#213;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x96"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"O"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#214;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x98"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"O"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#216;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x9F"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"Ss"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#223;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x99"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"U"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#217;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x9A"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"U"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#218;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x9B"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"U"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#219;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x9C"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"U"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#220;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\x9D"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"Y"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#221;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA0"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"a"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#224;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA1"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"a"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#225;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA2"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"a"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#226;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA3"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"a"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#227;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA4"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"a"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#228;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA5"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"a"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#229;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA6"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"a"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#230;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xBE"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"b"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#254;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA7"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"c"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#231;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC4\x87"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"c"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#263;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC4\x8D"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"c"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#269;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC4\x91"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"dj"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#273;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA8"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"e"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#232;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xA9"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"e"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#233;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xAA"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"e"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#234;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xAB"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"e"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#235;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xAC"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"i"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#236;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xAD"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"i"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#237;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xAE"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"i"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#238;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xAF"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"i"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#239;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB0"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"o"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#240;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB1"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"n"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#241;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB2"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"o"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#242;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB3"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"o"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#243;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB4"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"o"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#244;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB5"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"o"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#245;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB6"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"o"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#246;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB8"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"o"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#248;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC5\x94"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"R"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#340;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC5\x95"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"r"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#341;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC5\xA0"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"S"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#352;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC5\x9E"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"S"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#350;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC5\xA1"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"s"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#353;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xB9"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"u"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#249;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xBA"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"u"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#250;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xBB"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"u"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#251;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xBC"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"u"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#252;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xBD"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"y"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#253;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xBD"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"y"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#253;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC3\xBF"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"y"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#255;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC5\xBD"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"Z"&lt;/span&gt;, &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#381;
    &lt;/span&gt;                   &lt;span style="color: #bc8f8f;"&gt;"\xC5\xBE"&lt;/span&gt; =&amp;gt; &lt;span style="color: #bc8f8f;"&gt;"z"&lt;/span&gt;); &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;&amp;#382;
    &lt;/span&gt;
    $&lt;span style="color: #b8860b;"&gt;i18n&lt;/span&gt; = &lt;span style="color: #000000; background-color: #ffffff;"&gt;join(&lt;/span&gt;&lt;span style="color: #bc8f8f;"&gt;""&lt;/span&gt;, $&lt;span style="color: #b8860b;"&gt;internationalization&lt;/span&gt;);
    &lt;span style="color: #a020f0;"&gt;print&lt;/span&gt; $&lt;span style="color: #b8860b;"&gt;i18n&lt;/span&gt; . &lt;span style="color: #bc8f8f;"&gt;"\n"&lt;/span&gt;;

    &lt;span style="color: #b22222;"&gt;/**&lt;/span&gt;&lt;span style="color: #b22222;"&gt;
     * UTF-8 regular expression from
     * http://php.net/manual/en/function.utf8-decode.php (comment 57069)
     &lt;/span&gt;&lt;span style="color: #b22222;"&gt;*/&lt;/span&gt;
    $&lt;span style="color: #b8860b;"&gt;utf8_re&lt;/span&gt; = &lt;span style="color: #bc8f8f;"&gt;"/^([\\x00-\\x7f]|"&lt;/span&gt;
      . &lt;span style="color: #bc8f8f;"&gt;"[\\xc2-\\xdf][\\x80-\\xbf]|"&lt;/span&gt;
      . &lt;span style="color: #bc8f8f;"&gt;"\\xe0[\\xa0-\\xbf][\\x80-\\xbf]|"&lt;/span&gt;
      . &lt;span style="color: #bc8f8f;"&gt;"[\\xe1-\\xec][\\x80-\\xbf]{2}|"&lt;/span&gt;
      . &lt;span style="color: #bc8f8f;"&gt;"\\xed[\\x80-\\x9f][\\x80-\\xbf]|"&lt;/span&gt;
      . &lt;span style="color: #bc8f8f;"&gt;"\\xef[\\x80-\\xbf][\\x80-\\xbc]|"&lt;/span&gt;
      . &lt;span style="color: #bc8f8f;"&gt;"\\xee[\\x80-\\xbf]{2}|"&lt;/span&gt;
      . &lt;span style="color: #bc8f8f;"&gt;"\\xf0[\\x90-\\xbf][\\x80-\\xbf]{2}|"&lt;/span&gt;
      . &lt;span style="color: #bc8f8f;"&gt;"[\\xf1-\\xf3][\\x80-\\xbf]{3}|"&lt;/span&gt;
      . &lt;span style="color: #bc8f8f;"&gt;"\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})*$/"&lt;/span&gt;;

    &lt;span style="color: #a020f0;"&gt;print&lt;/span&gt; &lt;span style="color: #bc8f8f;"&gt;"Valid UTF-8?: "&lt;/span&gt; . (&lt;span style="color: #000000; background-color: #ffffff;"&gt;preg_match(&lt;/span&gt;$&lt;span style="color: #b8860b;"&gt;utf8_re&lt;/span&gt;, $&lt;span style="color: #b8860b;"&gt;i18n&lt;/span&gt;) &amp;gt; &lt;span style="color: #000000; background-color: #ffffff;"&gt;0&lt;/span&gt;
			      ? &lt;span style="color: #bc8f8f;"&gt;"true"&lt;/span&gt; : &lt;span style="color: #bc8f8f;"&gt;"false"&lt;/span&gt;) . &lt;span style="color: #bc8f8f;"&gt;"\n"&lt;/span&gt;;

    &lt;span style="color: #a020f0;"&gt;print&lt;/span&gt; &lt;span style="color: #000000; background-color: #ffffff;"&gt;strtr(&lt;/span&gt;$&lt;span style="color: #b8860b;"&gt;i18n&lt;/span&gt;, $&lt;span style="color: #b8860b;"&gt;utf8_dict&lt;/span&gt;) . &lt;span style="color: #bc8f8f;"&gt;"\n"&lt;/span&gt;;

    &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;Doesn't work in PHP4?
    &lt;/span&gt;$&lt;span style="color: #b8860b;"&gt;sorted&lt;/span&gt; = &lt;span style="color: #000000; background-color: #ffffff;"&gt;preg_split(&lt;/span&gt;&lt;span style="color: #bc8f8f;"&gt;"//u"&lt;/span&gt;, $&lt;span style="color: #b8860b;"&gt;i18n&lt;/span&gt;, -&lt;span style="color: #000000; background-color: #ffffff;"&gt;1&lt;/span&gt;, &lt;span style="color: #ff0000; font-weight: bold;"&gt;PREG_SPLIT_NO_EMPTY&lt;/span&gt;);
    &lt;span style="color: #b22222;"&gt;// &lt;/span&gt;&lt;span style="color: #b22222;"&gt;So, just use the original array, instead.
    &lt;/span&gt;$&lt;span style="color: #b8860b;"&gt;sorted&lt;/span&gt; = $&lt;span style="color: #b8860b;"&gt;internationalization&lt;/span&gt;;

    &lt;span style="color: #a020f0;"&gt;function&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;compare&lt;/span&gt;($&lt;span style="color: #b8860b;"&gt;s1&lt;/span&gt;, $&lt;span style="color: #b8860b;"&gt;s2&lt;/span&gt;)
    {
      &lt;span style="color: #a020f0;"&gt;global&lt;/span&gt; $&lt;span style="color: #b8860b;"&gt;utf8_dict&lt;/span&gt;;
      &lt;span style="color: #a020f0;"&gt;return&lt;/span&gt; &lt;span style="color: #000000; background-color: #ffffff;"&gt;strcasecmp(strtr(&lt;/span&gt;$&lt;span style="color: #b8860b;"&gt;s1&lt;/span&gt;, $&lt;span style="color: #b8860b;"&gt;utf8_dict&lt;/span&gt;),
			&lt;span style="color: #000000; background-color: #ffffff;"&gt;strtr(&lt;/span&gt;$&lt;span style="color: #b8860b;"&gt;s2&lt;/span&gt;, $&lt;span style="color: #b8860b;"&gt;utf8_dict&lt;/span&gt;));
    }

    &lt;span style="color: #000000; background-color: #ffffff;"&gt;usort(&lt;/span&gt;$&lt;span style="color: #b8860b;"&gt;sorted&lt;/span&gt;, &lt;span style="color: #bc8f8f;"&gt;"compare"&lt;/span&gt;);
    &lt;span style="color: #a020f0;"&gt;print&lt;/span&gt; &lt;span style="color: #000000; background-color: #ffffff;"&gt;join(&lt;/span&gt;&lt;span style="color: #bc8f8f;"&gt;""&lt;/span&gt;, $&lt;span style="color: #b8860b;"&gt;sorted&lt;/span&gt;) . &lt;span style="color: #bc8f8f;"&gt;"\n"&lt;/span&gt;;

    &lt;span style="color: #b22222;"&gt;/**&lt;/span&gt;&lt;span style="color: #b22222;"&gt;
     * Results:
     * 
     * I&amp;#241;t&amp;#235;rn&amp;#226;ti&amp;#244;n&amp;#224;liz&amp;#230;ti&amp;#248;n
     * Valid UTF-8?: true
     * Internationalization
     * &amp;#224;&amp;#230;&amp;#226;&amp;#235;Iiiil&amp;#241;nnn&amp;#248;&amp;#244;rtttz
     &lt;/span&gt;&lt;span style="color: #b22222;"&gt;*/&lt;/span&gt;
    &lt;span style="color: #da70d6;"&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;I tried the &lt;a href="http://pear.php.net/package/I18N_UnicodeNormalizer" target="_blank" rel="nofollow"&gt;I18N_UnicodeNormalizer&lt;/a&gt; from the PHP PEAR project, and it didn't do what I wanted.&lt;/p&gt;

&lt;pre&gt;
    &lt;span style="color: #da70d6;"&gt;&amp;lt;?php&lt;/span&gt;

    &lt;span style="color: #a020f0;"&gt;require_once&lt;/span&gt;(&lt;span style="color: #bc8f8f;"&gt;'I18N/UnicodeNormalizer.php'&lt;/span&gt;);

    &lt;span style="color: #a020f0;"&gt;print&lt;/span&gt; &lt;span style="color: #228b22;"&gt;I18N_UnicodeNormalizer&lt;/span&gt;::&lt;span style="color: #000000; background-color: #ffffff;"&gt;toNFD(&lt;/span&gt;$&lt;span style="color: #b8860b;"&gt;i18n&lt;/span&gt;) . &lt;span style="color: #bc8f8f;"&gt;"\n"&lt;/span&gt;;
    &lt;span style="color: #a020f0;"&gt;print&lt;/span&gt; &lt;span style="color: #228b22;"&gt;I18N_UnicodeNormalizer&lt;/span&gt;::&lt;span style="color: #000000; background-color: #ffffff;"&gt;toNFC(&lt;/span&gt;$&lt;span style="color: #b8860b;"&gt;i18n&lt;/span&gt;) . &lt;span style="color: #bc8f8f;"&gt;"\n"&lt;/span&gt;;
    &lt;span style="color: #da70d6;"&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;There's a good chance I don't know what I'm doing there with the PEAR library, however.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:23852</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/23852.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=23852"/>
    <title>Unicode hex in PHP string</title>
    <published>2009-05-27T18:33:38Z</published>
    <updated>2009-05-27T22:35:17Z</updated>
    <category term="programming"/>
    <category term="php"/>
    <category term="emacs"/>
    <category term="howto"/>
    <content type="html">&lt;p&gt;In Emacs, insert UTF-8 hex value for a PHP string of the character at point.&lt;/p&gt;

&lt;pre&gt;
(defun php-hex-for-char ()
  (interactive)
  (insert
   (mapconcat (lambda (x) (format "\\x%02X" x))
              (encode-coding-char (char-after (point)) 'utf-8)
              "")))

&lt;/pre&gt;

&lt;p&gt;Lisp lifted from `describe-char' and `encoded-string-description'.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:23429</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/23429.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=23429"/>
    <title>Shell hack: Files with some DOS lines</title>
    <published>2009-05-18T22:26:06Z</published>
    <updated>2009-05-21T13:17:48Z</updated>
    <category term="programming"/>
    <category term="unix"/>
    <category term="howto"/>
    <category term="free software"/>
    <content type="html">&lt;p&gt;I came across a project whose source code contains both DOS text files and Unix text files.  Some of the Unix files contain carriage return line endings.  Though, perhaps they were DOS files with Unix end lines!  I wanted to suggest converting those files with mixed line endings to Unix.&lt;/p&gt;

&lt;p&gt;Sometimes, the &lt;tt&gt;file&lt;/tt&gt; command is helpful for showing what files have a mixed end of line style, but not always.  For example, the &lt;tt&gt;file&lt;/tt&gt; command will say "ASCII C program text, with CRLF, LF line terminators".  That's perfect.  However, sometimes the command just says, "PHP script text".&lt;/p&gt;

&lt;p&gt;I wrote this &lt;tt&gt;find&lt;/tt&gt; expression that would get files that contain DOS carriage returns, but not entirely DOS files.&lt;/p&gt;

&lt;pre&gt;
$ find -type f -execdir grep -qe '^V^M$' {} \; \
       ! -execdir awk 'BEGIN{is_dos=1;}!/\r$/{is_dos=0}END{exit(!is_dos);}' {} \; \
       -print
&lt;/pre&gt;

&lt;p&gt;The above doesn't work, since many DOS files don't end in a newline (and without a carriage return) as they do for Unix text files.&lt;/p&gt;

&lt;p&gt;Awk obviously considers the last line as a line, but since there's no carriage return the file is not considered a DOS file based on the logic I've written.  This results in a false negative.&lt;/p&gt;

&lt;p&gt;This change to the Awk script makes this hack work as it should.&lt;/p&gt;

&lt;pre&gt;
$ find -type f -execdir grep -qe '^V^M$' {} \; \
       ! -execdir awk 'BEGIN{is_dos=1;}
                       !/\r$/ &amp;&amp; is_dos{is_dos=0;n=NR}
                       END{exit(!is_dos &amp;&amp; n != NR);}' {} \; \
       -print
&lt;/pre&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:23288</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/23288.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=23288"/>
    <title>Send Amazon's Bezos some peaches</title>
    <published>2009-05-13T20:43:10Z</published>
    <updated>2009-05-13T21:30:02Z</updated>
    <category term="free software"/>
    <content type="html">I just noticed there was a great action by the FSF's anti-DRM campaign last month against Amazon's Kindle electronic book.  See &lt;a href="http://www.defectivebydesign.org/impeach-jeff-bezos-for-kindle-swindle" target="_blank" rel="nofollow"&gt;Defective by Design: Impeach Bezos for Amazon's Kindle Swindle&lt;/a&gt;.  The idea is to send baby food peaches to Jeff Bezos for having terms that allow Amazon to deny customer's access to read their electronic books.&lt;br /&gt;&lt;br /&gt;Sending baby food is pretty easy in the age of the Internet, see the link and instructions at the end of the post.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:22856</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/22856.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=22856"/>
    <title>Change log entries for HTML files</title>
    <published>2009-05-05T18:08:18Z</published>
    <updated>2009-05-05T20:45:53Z</updated>
    <category term="programming"/>
    <category term="emacs"/>
    <category term="howto"/>
    <category term="free software"/>
    <content type="html">&lt;p&gt;Someone asked me if there was a good way to annotate the changes of an HTML file.  It sounded like the person had to maintain some legacy, HTML-hell, home-brewed, template files for some business Web site.&lt;/p&gt;

&lt;p&gt;I suggested using the &lt;a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Change-Log.html" target="_blank" rel="nofollow"&gt;ChangeLog support of Emacs&lt;/a&gt;, and using HTML comments to organize sections of an HTML source file.  Here's a simple, made-up example of such an HTML file.&lt;/p&gt;

&lt;pre&gt;
&amp;lt;&lt;span style="color: #0000ff;"&gt;html&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style="color: #0000ff;"&gt;head&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style="color: #0000ff;"&gt;title&lt;/span&gt;&amp;gt;&lt;span style="font-weight: bold; text-decoration: underline;"&gt;Sample only&lt;/span&gt;&amp;lt;/&lt;span style="color: #0000ff;"&gt;title&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style="color: #0000ff;"&gt;head&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style="color: #0000ff;"&gt;body&lt;/span&gt;&amp;gt;
&lt;span style="color: #b22222;"&gt;&amp;lt;!-- begin header --&amp;gt;&lt;/span&gt;
&amp;lt;&lt;span style="color: #0000ff;"&gt;p&lt;/span&gt;&amp;gt;[ &amp;lt;&lt;span style="color: #0000ff;"&gt;a&lt;/span&gt; &lt;span style="color: #b8860b;"&gt;id&lt;/span&gt;=&lt;span style="color: #bc8f8f;"&gt;"top"&lt;/span&gt; &lt;span style="color: #b8860b;"&gt;href&lt;/span&gt;=&lt;span style="color: #bc8f8f;"&gt;"#bottom"&lt;/span&gt;&amp;gt;bottom&amp;lt;/&lt;span style="color: #0000ff;"&gt;a&lt;/span&gt;&amp;gt; ]&amp;lt;/&lt;span style="color: #0000ff;"&gt;p&lt;/span&gt;&amp;gt;
&lt;span style="color: #b22222;"&gt;&amp;lt;!-- end header --&amp;gt;&lt;/span&gt;
&amp;lt;&lt;span style="color: #0000ff;"&gt;h1&lt;/span&gt;&amp;gt;&lt;span style="font-weight: bold; text-decoration: underline;"&gt;Sample title&lt;/span&gt;&amp;lt;/&lt;span style="color: #0000ff;"&gt;h1&lt;/span&gt;&amp;gt;
&lt;span style="color: #b22222;"&gt;&amp;lt;!-- BEGIN: PAGE_CONTENT --&amp;gt;&lt;/span&gt;
&amp;lt;&lt;span style="color: #0000ff;"&gt;div&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style="color: #0000ff;"&gt;p&lt;/span&gt;&amp;gt;Testing.&amp;lt;/&lt;span style="color: #0000ff;"&gt;p&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style="color: #0000ff;"&gt;div&lt;/span&gt;&amp;gt;
&lt;span style="color: #b22222;"&gt;&amp;lt;!-- END: PAGE_CONTENT --
  -- footer-bottom start --&amp;gt;&lt;/span&gt;
&amp;lt;&lt;span style="color: #0000ff;"&gt;p&lt;/span&gt;&amp;gt;[ &amp;lt;&lt;span style="color: #0000ff;"&gt;a&lt;/span&gt; &lt;span style="color: #b8860b;"&gt;id&lt;/span&gt;=&lt;span style="color: #bc8f8f;"&gt;"bottom"&lt;/span&gt; &lt;span style="color: #b8860b;"&gt;href&lt;/span&gt;=&lt;span style="color: #bc8f8f;"&gt;"#top"&lt;/span&gt;&amp;gt;top&amp;lt;/&lt;span style="color: #0000ff;"&gt;a&lt;/span&gt;&amp;gt; ]&amp;lt;/&lt;span style="color: #0000ff;"&gt;p&lt;/span&gt;&amp;gt;
&lt;span style="color: #b22222;"&gt;&amp;lt;!-- footer-bottom end --&amp;gt;&lt;/span&gt;
&amp;lt;/&lt;span style="color: #0000ff;"&gt;body&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style="color: #0000ff;"&gt;html&lt;/span&gt;&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Unfortunately, support for either the above sectioning style, or even another alternative, is not provided by the &lt;a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/HTML-Mode.html" target="_blank" rel="nofollow"&gt;HTML mode&lt;/a&gt; that ships with Emacs.  This is understandable because there is no consistent standard of doing this, and people use other variations than even those covered in the example.  Not to mention, HTML comments are used for other reasons than naming regions of the file.&lt;/p&gt;

&lt;p&gt;Regardless, I've put together the following regular expression for &lt;code&gt;add-log-current-defun-header-regexp&lt;/code&gt;.  It handles the cases in the example above.  It is set for all buffers using HTML mode.  Just put the following in your &lt;a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html" target="_blank" rel="nofollow"&gt;&lt;tt&gt;.emacs&lt;/tt&gt; file&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;
    (add-hook 'html-mode-hook
        (lambda ()
          (make-local-variable
           'add-log-current-defun-header-regexp)
           (setq add-log-current-defun-header-regexp
               (concat "^[ \t]*&amp;lt;?!?--[ \t]*\\(?:begin\\|BEGIN\\|start\\)?"
                       "[ \t:]*\\([-_[:alnum:]]+\\)"
                       "[ \t]*\\(?:begin\\|BEGIN\\|start\\)?[ \t]*--"))))
&lt;/pre&gt;

&lt;p&gt;Use it by typing `&lt;kbd&gt;C-x 4 a&lt;/kbd&gt;' (&lt;tt&gt;add-change-log-entry-other-window&lt;/tt&gt;).  An entry like the following will be added in a nearby &lt;tt&gt;ChangeLog&lt;/tt&gt; file:&lt;/p&gt;
    &lt;pre&gt;
&lt;span style="color: #bc8f8f;"&gt;2009-05-05  &lt;/span&gt;&lt;span style="color: #5f9ea0;"&gt;Aaron S. Hawley&lt;/span&gt;  &amp;lt;&lt;span style="color: #b8860b;"&gt;aaronhawley@livejournal.com&lt;/span&gt;&amp;gt;

        * &lt;span style="color: #0000ff;"&gt;file.html&lt;/span&gt; (&lt;span style="color: #a020f0;"&gt;PAGE_CONTENT&lt;/span&gt;): Add a test paragraph.
        (&lt;span style="color: #a020f0;"&gt;footer-bottom&lt;/span&gt;): Added link to "#top".
&lt;/pre&gt;

&lt;p&gt;This setup will work for most cases except for scenarios where there is nested sectioning or where you've run `&lt;kbd&gt;C-x 4 a&lt;/kbd&gt;' from a point outside of a "section" and get a false-positive.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:22779</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/22779.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=22779"/>
    <title>Shell hack: Avoiding built-ins</title>
    <published>2009-05-01T09:26:43Z</published>
    <updated>2009-05-02T18:22:53Z</updated>
    <category term="unix"/>
    <category term="programming languages"/>
    <category term="howto"/>
    <category term="free software"/>
    <content type="html">&lt;p&gt;To avoid using a &lt;em&gt;builtin&lt;/em&gt; command of a Bourne or Bash shell in a shell script, one can use the full path of the executable command.  For example, rather than&lt;/p&gt;

&lt;pre&gt;
$ echo Hello, World\!
Hello, World!
&lt;/pre&gt;

&lt;p&gt;you could&lt;/p&gt;

&lt;pre&gt;
$ /bin/echo Hello, World\!
Hello, World!
&lt;/pre&gt;

&lt;p&gt;Here's a way to show the difference--and make fun of the &lt;a href="http://www.gnu.org/prep/standards/" target="_blank" rel="nofollow"&gt;GNU coding standards&lt;/a&gt; at the same time.&lt;/p&gt;

&lt;pre&gt;
$ echo --version
--version
&lt;/pre&gt;

&lt;pre&gt;
$ /bin/echo --version
echo (GNU coreutils) 6.12
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3 : GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Brian Fox and Chet Ramey.
&lt;/pre&gt;

&lt;p&gt;I prefer to use &lt;code&gt;exec&lt;/code&gt; than using the full path for a command so that the &lt;tt&gt;PATH&lt;/tt&gt; environment variable is used, and avoid the day should the full path to a binary change some day.&lt;/p&gt;

&lt;p&gt;Unfortunately, a consequence of &lt;code&gt;exec&lt;/code&gt; is that it runs the command in the current process and therefore will exit on completion, thus cutting short the life of your shell script.  To avoid that, just wrap an exec statement in a sub-shell by using parens:&lt;/p&gt;

&lt;pre&gt;
$ ( exec echo --version )
echo (GNU coreutils) 6.12
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3 : GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Brian Fox and Chet Ramey.
&lt;/pre&gt;

&lt;p&gt;I have never seen this written in a script before.  Perhaps, there's another way--that's a bit more canonical--to do this.  This construct is entirely redundant and contradictory--"exec something in the current shell, but also in a sub-shell".  Further, it's probably pretty much always the case to opt for the shell built-in.  There are zero to no cases where you want to avoid the built-in.  My only scenarios are &lt;a href="http://aaronhawley.livejournal.com/9225.html" target="_blank"&gt;timing processes in the shell&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;According to the &lt;a href="http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Builtins.html" target="_blank" rel="nofollow"&gt;Limitations of Shell Builtins&lt;/a&gt; section of the GNU Autoconf manual,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When it is desired to avoid a regular shell built-in, the workaround is
to use some other forwarding command, such as &lt;samp&gt;&lt;span class=""&gt;env&lt;/span&gt;&lt;/samp&gt; or
&lt;samp&gt;&lt;span class=""&gt;nice&lt;/span&gt;&lt;/samp&gt;, that will ensure a path search:&lt;/p&gt;

     &lt;pre class=""&gt;          $ &lt;kbd&gt;pdksh -c 'exec true --version' | head -n1&lt;/kbd&gt;

          $ &lt;kbd&gt;pdksh -c 'nice true --version' | head -n1&lt;/kbd&gt;
          true (GNU coreutils) 6.10
          $ &lt;kbd&gt;pdksh -c 'env true --version' | head -n1&lt;/kbd&gt;
          true (GNU coreutils) 6.10
     &lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;That manual has everything it it.  I guess I'll go with &lt;code&gt;env&lt;/code&gt;, doesn't sound as nice as "&lt;code&gt;exec&lt;/code&gt;", but it's a good mnemonic since it use the &lt;em&gt;environment&lt;/em&gt;'s path variable to run the command.&lt;/p&gt;

&lt;pre&gt;
$ env echo --version
echo (GNU coreutils) 6.12
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Brian Fox and Chet Ramey.
&lt;/pre&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:21792</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/21792.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=21792"/>
    <title>Shell hack: Date work</title>
    <published>2009-04-26T05:42:40Z</published>
    <updated>2009-04-27T03:48:46Z</updated>
    <category term="programming"/>
    <category term="unix"/>
    <category term="howto"/>
    <category term="free software"/>
    <content type="html">&lt;p&gt;Needed to make some &lt;a href="http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect" target="_blank" rel="nofollow"&gt;Apache redirects&lt;/a&gt; for some links on a unix user's group Web site I maintain.  The new site is based in a Wiki, and a member of the group moved all the pages with meeting announcements by hand using more readable page names.  The old pages had the data as a four-digit year, two-digit month followed by the two-digit day (for example, &lt;samp&gt;20061219&lt;/samp&gt;).  The new pages have the spelled out version of the week day and month (for example, &lt;samp&gt;Tuesday, December 19, 2006&lt;/samp&gt;).&lt;/p&gt;

&lt;p&gt;Here's a sample of what I needed for the &lt;tt&gt;.htaccess&lt;/tt&gt; file.&lt;/p&gt;

&lt;pre&gt;
Redirect /group/meeting-20061219.html   http://host.org/group/wiki/index.php/Tuesday,_December_19,_2006
Redirect /group/meeting-20070417.html   http://host.org/group/wiki/index.php/Tuesday,_April_17,_2007
Redirect /group/meeting-20070515.html   http://host.org/group/wiki/index.php/Tuesday,_May_15,_2007
Redirect /group/meeting-20070717.html   http://host.org/group/wiki/index.php/Tuesday,_July_17,_2007
Redirect /group/meeting-20071128.html   http://host.org/group/wiki/index.php/Wednesday,_November_28,_2007
Redirect /group/meeting-20080618.html   http://host.org/group/wiki/index.php/Wednesday,_June_18,_2008
&lt;/pre&gt;

&lt;p&gt;I could do this by-hand, but I'd rather get a shell script to do it right, the first time.  I found it easy to do with an &lt;a href="http://www.gnu.org/software/grep/doc/grep_12.html" target="_blank" rel="nofollow"&gt;extended Grep expression&lt;/a&gt;, &lt;a href="http://www.gnu.org/software/gawk/" target="_blank" rel="nofollow"&gt;awk&lt;/a&gt; and the &lt;tt&gt;date&lt;/tt&gt; command that comes with &lt;a href="http://www.gnu.org/software/coreutils/" target="_blank" rel="nofollow"&gt;GNU coreutils&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;
$ ls -1 \
  | grep -Ee '[0-9]{8}.html$' \
  | perl -pe 's/([0-9]{4})([0-9]{2})([0-9]{2}).html$/$&amp;\t\1-\2-\3/' \
  | awk '{printf $1 "\t";
          system("date +\"%A,_%B_%e,_%Y\" -d "  $2);}' \
  | awk '{print "Redirect", "/group/" $1,
                "http://host.org/group/wiki/index.php/" $2;}'
&lt;/pre&gt;

&lt;p&gt;I'm thankful I consistently used a file naming convention with the old site.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:21687</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/21687.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=21687"/>
    <title>Database programming</title>
    <published>2009-04-24T01:26:36Z</published>
    <updated>2009-04-24T16:01:12Z</updated>
    <category term="database"/>
    <category term="programming"/>
    <category term="free software"/>
    <category term="software"/>
    <content type="html">&lt;p&gt;This simple bit of PHP made some changes to a MediaWiki installation for me recently.  Don't use it.  My point here is in showing the satisfaction from changing a database with code that generates the SQL statements for you.   The golden rule for database applications is to make sure there's an interface or programming layer to the actual database to preserve data integrity and keep changes limited in scope.  One should use some of the scripts that come with MediaWiki--&lt;code&gt;batchMove.php&lt;/code&gt; or &lt;code&gt;namespaceDupes.php&lt;/code&gt; for example--to do this.  Such scripts are better trusted, but also handle the schema should it change in a later release of the software.&lt;/p&gt;

&lt;p&gt;Now that the disclaimer is out of the way, I was pleasantly surprised how consistent the schema for MediaWiki was for allowing me to rely on simple data structures and some for-loops to update 9 tables.  Clearly, the schema isn't entirely normalized, but I predict there is a rationale for having some of the data &lt;a href="http://en.wikipedia.org/wiki/Denormalization" target="_blank" rel="nofollow"&gt;denormalized&lt;/a&gt;.  Given this scenario, it is a real compliment to a software package and its schema if one can write very concise code to generate a series of SQL statements for a task.&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php
// Move 3 pages, and start 2 namespaces.  Don't use this code!

$table = array('page' =&amp;gt; 'mw_page',
	       'rc' =&amp;gt; 'mw_recentchanges',
	       'pl' =&amp;gt; 'mw_pagelinks',
	       'pt' =&amp;gt; 'mw_protected_titles',
	       'qc' =&amp;gt; 'mw_querycache',
	       'qcc' =&amp;gt; 'mw_querycachetwo',
	       'rd' =&amp;gt; 'mw_redirect',
	       'tl' =&amp;gt; 'mw_templatelinks',
	       'wl' =&amp;gt; 'mw_watchlist');

$namespaces = array(100 =&amp;gt; 'ThisWiki',
		    /* 101 =&amp;gt; 'ThisWiki talk', */
		    110 =&amp;gt; 'RPM',
		    /* 111 =&amp;gt; 'RPM talk' */);

$rename = array('Changes_to_Wiki_database' =&amp;gt; 'ThisWiki:Changes_to_database',
		'LocalSettings.php' =&amp;gt; 'ThisWiki:LocalSettings.php',
		'Changes_to_Monobook_skin'
		  =&amp;gt; 'ThisWiki:Changes_to_Monobook_skin');

foreach ($table as $short =&amp;gt; $t) {
  // Move:
  foreach ($rename as $orig =&amp;gt; $new) {
    foreach (array(0 =&amp;gt; '', 1 =&amp;gt; 'Talk') as $old_ns =&amp;gt; $old_name) {
      printf("UPDATE %s\n"
	     . "SET %s_title = '%s'\n"
	     . "WHERE %s_title = '%s' AND %s_namespace = %d;\n",
	     $t, $short, $new, $short, $orig, $short, $old_ns);
    }
  }
  // Fix namespace:
  foreach ($namespaces as $num =&amp;gt; $name) {
    foreach (array(0 =&amp;gt; '', 1 =&amp;gt; 'Talk') as $old_ns =&amp;gt; $old_name) {
      printf("UPDATE %s\n"
	     . "SET %s_title = REPLACE(%s_title, '%s:', ''), "
	     . "%s_namespace = %d\n"
	     . "WHERE %s_title LIKE '%s:%%' AND %s_namespace = %d;\n",
	     $t, $short, $short, $name, $short, $num + $old_ns,
	     $short, $name, $short, $old_ns);
    }
  }
}
?&amp;gt;
&lt;/pre&gt;

&lt;p&gt;It's dangerous to show this code, because someone may come to this page after a Web search and erroneously think this is the way to introduce namespaces in MediaWiki or something.  I'll say it again: Don't use this!&lt;/p&gt;

&lt;p&gt;Unfortunately, generating SQL statements by-hand is a dirty little secret of database maintenance.  I've seen database maintenance done by evaluating SQL commands one-at-time more often than I'd like.  Instead of being programmatic and more efficient, "easter egging" methods often introduce typos by either rousing "copy and paste" hell or a "search and replace" hell, and therefore risks typo errors and who knows what else.  Writing database maintenance scripts programmaticaly enables you to work as a single transaction and study the results in each iteration.  This quality forces one to use a test version of the data and avoid another database &lt;em&gt;faux pas&lt;/em&gt; -- working on live databases.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:aaronhawley:21031</id>
    <link rel="alternate" type="text/html" href="https://aaronhawley.livejournal.com/21031.html"/>
    <link rel="self" type="text/xml" href="https://aaronhawley.livejournal.com/data/atom/?itemid=21031"/>
    <title>Study Emacs with Lisp or natural language?</title>
    <published>2009-04-19T06:08:32Z</published>
    <updated>2009-04-19T06:23:03Z</updated>
    <category term="programming"/>
    <category term="emacs"/>
    <category term="free software"/>
    <category term="software"/>
    <content type="html">There was a back and forth between Emacs bloggers Jared Dilettante and Ian Eure about whether Emacs users should &lt;a href="http://curiousprogrammer.wordpress.com/2009/04/16/dangerous-elisp/" target="_blank" rel="nofollow"&gt;write Emacs Lisp code for their own purposes&lt;/a&gt; or whether &lt;a href="http://atomized.org/2009/04/central-documentation-and-wasted-effort/" target="_blank" rel="nofollow"&gt;working in Emacs Lisp should primarily be in support of existing modes&lt;/a&gt;--and with the mode's documentation thoroughly read.  At this point, the argument has fizzled out, but its worth pointing out that a manual for &lt;a href="http://www.geocities.com/kensanata/emacs-sql.html" target="_blank" rel="nofollow"&gt;SQL mode&lt;/a&gt; doesn't seem to exist.  SQL mode, like most Emacs modes, is &lt;a href="http://www.emacswiki.org/emacs/SelfDocumentation" target="_blank" rel="nofollow"&gt;self-documented&lt;/a&gt; well.  However, this argument is evidence that it could probably use a manual.&lt;br /&gt;&lt;br /&gt;As someone who's neither a trained writer nor a good one, I know that writing in one's own spoken language is difficult.  However, writing concise documentation about Emacs can be just as important as writing Emacs Lisp code, if not maybe more so.  Writing documentation will give you a deeper understanding of how something works and help you learn things you didn't already know.   It's also important because the documentation you write will help someone else to learn how to use Emacs, too.&lt;br /&gt;&lt;br /&gt;Documenting Emacs also improves your Emacs Lisp skills because you'll likely be reading other hacker's Emacs Lisp code.  Most important of all you'll be working on existing code for Emacs rather than making more when it is not entirely necessary to reinvent the wheel.&lt;br /&gt;&lt;br /&gt;Don't get me wrong.  It's fine to twiddle code.  Reinventing the wheel is the basis for higher education and university study and critical to life-long learning.  However, writing code and championing your work as a solution only acts to avoid studying and maintaining existing code and risks distracting the Emacs community from progress.  In a way, it's almost anti-social.&lt;br /&gt;&lt;br /&gt;I know some Emacs hackers think multiple implementations are important, and "I wouldn't have learned as much if I didn't manage my own Emacs package".  These arguments are spurious, though.  One should be able to earn these same benefits--and more--by joining in on an existing project, rather than forking a new one.  It may take more effort but its the right thing to do and is under my column of "best practices".&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://www.gnu.org/copyleft/gpl.html" target="_blank" rel="nofollow"&gt;GNU General Public License&lt;/a&gt; gives the Emacs hacker a lot of freedom, but we all could still use the occasional self-discipline.</content>
  </entry>
</feed>
