Technology

Switching keys in values in a map

A functor that reverses a pair: first becomes second,
second becomes first. Useful for switching
from a map to another map (or multimap in this example) where
the value becomes the key and the key the value.

std::map<std::string, int> m;
std::multimap<int,std::string> m2;
m["a"] = 0;
m["b"] = 1;
m["c"] = 0;
std::transform (m.begin(), m.end(), std::inserter (m2, m2.begin()),
                pair_switch());

And the actual code:

template<class PairType>
struct pair_switcher : public std::unary_function<PairType, std::pair<a,b>
{
 typedef std::pair result_type;
 typedef PairType argument_type;
 result_type operator()(const argument_type &p) const
 {
     return result_type (p.second, p.first);
 }
};
Technology

WordPress 3.0 update

Update to 3.0 went pretty smoothly. I’m having some problem with images (added how to fix below)

  • Ran my custom backup script:
$ cd ~/Desktop/wp-backup
$ ./backup
  
  • Downloaded wordpress 3.0:
$ cd ~/Desktop/src/downloads/pkgs
$ curl -O http://wordpress.org/latest.tar.gz
$ mv latest.tar.gz wordpress-3.0.tgz
  
  • Make sure you know the WP administrator user password as WP 3.0 uses a “Super Admin” interface.
  • No real special requirements for my site for wpmu upgrade most a lot of warnings about plugins and themes not necessarily being compatible.
  • Follow the directions or these even better directions
    • Disable plugins from site admin web page
    • Remove (save somewhere else) wp-admin, wp-includes
    • Extract the wordpress-3.0.files
    • Fix permisions (this is Apple’s Snow Leopard Server)
$ cd /Library/Webserver/Documents
$ mv wp-admin wp-includes ~/tmp
$ tar xzvf ~/Desktop/src/downloads/pgks/wordpress-3.0.tgz
$ chown -R _www:_www .
  
  • remove blogs.php
$ cd /Library/Webserver/Documents
$ rm wp-content/blogs.hp
  
  • Modify .htaccess to add the rule for wp-files (replacings blogsphp):
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
  
  • Upgrade the site (site.com/wp-admin/upgrade.php). Login as the administrator user, if you don’t see “Super Admin” you aren’t the right user.
  • My site admin had some extra steps to perform like getting rid of blogs.php and adding some code
    for the cookies.
  • Update the plugins
Technology

Jeopardy playing computer

From NY Times is this article Smarter Than You Think – I.B.M.’s Supercomputer Challenges ‘Jeopardy!’ Champions – NYTimes.com about how IBM has built a machine that does pretty well playing Jeopardy.

Neither, as it turned out. Both were beaten to the buzzer by the third combatant: Watson, a supercomputer.

For the last three years, I.B.M. scientists have been developing what they expect will be the world’s most advanced “question answering” machine, able to understand a question posed in everyday human elocution — “natural language,” as computer scientists call it — and respond with a precise, factual answer.

Politics

Budget Deficits

Deficit1

Here’s how future US budget deficits are apportioned to various legislation and events from Center on Budget and Policy Priorities. Remember, the budget for 2000 was in surplus; in 2009 the deficit was $1.4 trillion. It’s not the stimulus spending that dominates deficit spending.

12 16 09bud rev6 28 10 t11

In the meantime, employment is still terrible. If the employment rate stayed at the same rate as 1999 67.1% then there are four million fewer jobs then 10 years ago. That’s a lot of unhappy people.

News · Politics

Unemployment

Here’s is Calculated Risk’s version of the scariest chart. It shows the change in employment as a percent since the peak employment near the beginning of the recession; for this recession, that’s Dec 2007. Don’t forget that the years up to 2007 weren’t particularly good as there was no net gain of jobs in spite of increasing population.
Inflation is at 2.2% which is lower then usual.
The dotted line is employment with the census workers taken out.

Employment an Recessions May 20101

Politics

High tax rates and economic growth

From Paul Krugman is this interesting chart about the upper tax rate. I don’t think (and I doubt anyone else does) that high taxes/high regulation cause growth but it is clear that low taxes/low regulation are not the be-all/end-all of economic policies.

The blue line, left scale, shows median family income in 2008 dollars; the red line, right scale, shows the top marginal tax rate, a rough indicator of the overall stance of policy. Basically, US postwar economic history falls into two parts: an era of high taxes on the rich and extensive regulation, during which living standards experienced extraordinary growth; and an era of low taxes on the rich and deregulation, during which living standards for most Americans rose fitfully at best.

taxes-growth.png
The Krugman post was inspired by Richard Green who got the data from US Dept of Commerce’s Bureau of Economic Analysis
And I still like the earlier comic I posted from The Politics in Deficits & Taxes
grab-004.png