Pete Ware

Tech, NYC & Politics

Tag: Technology (page 1 of 2)

C++ test for within

I found myself having to write a bunch of range checking code like this:

so I wrote this simple function.
Continue reading

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.

And the actual code:

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.

Purpose vs. Profit Motive

Daniel Pink has some surprising results about what motivates people. Mostly, if there’s any creativity, then more money doesn’t provide more motivation — and may even unmotivate.

Doug Green has a detailed review of this book — I
saved a copy.

You can also check out an animated version of a talk by Daniel Green:

”Drive”

Xcode: notes

To reset Xcode to the default settings:

First, I dislike having a lot of popup windows so I set the layout to “All-In-One” to keep most things within a single window:

grab-001.png

And my usual indentation style:

grab-003.png

I like having the files autosaved on build:

=grab-007.png

Google dominating search

There’s talk that Bing has gotten to a 10% market share in search. Apple Insider instead points out that the study didn’t include a big part of Google’s search business (you know, maps, video, local directory). Here’s a chart showing how Google is dominating and pushing nearly 90%:

google-share.png

Delay

Sorry for the long delay. I’ve been playing around a bit.

sqlite3 rocks

I’d been using the sqlite3 that came installed on Mac OS X but I ran into some portability issues — not every system has it installed. So I decided to bite the bullet and include it with my code.

It was trivial! I downloaded a zip with 3 files (sqlite3.c,sqlite3.h, and sqlite3ext.h). Added sqlite3.c to my list of sources and it just compiled! No configuration, no trickly flags, it just worked!

Getting the keys from a std::map

So last week I wrote about initializing a std::map from two std::vectors. How about doing the reverse? How do I get a list of the keys or a list of the values into a vector?

So I wrote a functor, based on std::unary_function, that returns the pair.first and another that returns the pair.second:
Continue reading

Functor for deleting objects

In a destructor for a class, I had a std::vector of pointers that I wanted to delete. I started to write the usual for(;;) loop and realized I do this often enough I should make it easy to use std::for_each().

Here’s the functor (based on std::unary_function):

And here’s some sample code using it:

I added a return of true because some other template code wasn’t happy about “return void” — supposedly something fixed in recent compilers.

Older posts

© 2017 Pete Ware

Theme by Anders NorenUp ↑