Sample Koala-Facebook Ruby on Rails App

Posted by banane on January 22nd, 2012 — in facebook, ruby on rails

Back on my old post: “Ruby on Rails and Facebook API (Koala): Basic Example” there was a request for either sample code, or more detail. I’ve setup an app in Github: “Sample Koala Rails Test.”. You can get that code by putting the following on your server:

git clone git://github.com/banane/sample-koala-rails-app.git

Or, just read it online at GitHub. Please remove my app id and secret if you implement.

Important Step
Setup your Facebook app for local development on your computer. To do this, set the site_url to “http://localhost:3000/” (or whatever port you are running your Rails server).

1. Create your own Facebook app.

2. Copy the application id, secret, and url into the /config/initilizers/constants.rb file. Don’t use mine!

3. Run the server: “rails s”

4. Access in a browser http://localhost:3000

5. Click the “authenticate this app” button, and you will go through the authentication flow for gaining credentials to Facebook data, as a user.

6. The next view displays your recent statuses.

What’s going on?

Well, quite a lot, it turns out.

You’re setting up authentication between the Facebook server, your local application, and the user. It’s well explained in the Facebook Developer Authentication Guide, though written for PHP and JavaScript developers, mainly. What we’re doing is “Facebook Application” authentication, even though we’re not hosting it inside an iFrame on Facebook itself (which is totally possible, I just didn’t do it for simplicity’s sake).

First, we setup a Koala object

  1. session[:oauth] = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, SITE_URL + ‘/home/callback’)

Passing to it our Facebook application constants. We will use this session variable throughout the app.
Next, we derive a “authentication url”, and pass to it a string that represents the access we’d like to have. In this example, it’s “read_stream”- accessing the user’s statuses (chart of Facebook permissions).

  1. @auth_url =  session[:oauth].url_for_oauth_code(:permissions=>"read_stream")

Koala takes this information and creates an “auth_url”- a link to the Facebook auth services. We use this variable in our index.html.erb view, to direct the user to authenticate. Facebook checks the user to see if they’re logged in and already authorized for the app. If not, it leads them through a series of screens to explain and request permission. You noticed when we setup the Koala session variable “oauth”, that we included a redirect uri. This is where we want the user to land after authentication. In rails, it’s a controller/method combination. We’re sending them, in this example, to “home/callback.”

In the callback method, the authentication is still not complete. We receive a “code” in the GET string, which we send to the “oauth” session object.

  1. if params[:code]
  2.      # acknowledge code and get access token from FB
  3.      session[:access_token] = session[:oauth].get_access_token(params[:code])
  4. end

Koala sends this to Facebook (largely in the background) requesting the final token, the “access token.” Then, we send this access token to Koala object, which then enables us to use the Koala methods to retrieve data from Facebook.

We query the Facebook data with the “get_object” method, and pass to it two arguments, first the object (me) and the connection, “statuses.” It is well explained in Facebook’s description of the User graph object. Farther down you can read about the other available connections, and, you can query the data through the Explorer Tool – very handy.

  1. @api = Koala::Facebook::API.new(session[:access_token])
  2. @graph_data = @api.get_object("/me/statuses", "fields"=>"message")

The result is a hash, “GraphCollection.” I minimized the data result by setting the specific fields in “statuses” to return. That is the second argument in “get_object” method, “fields”=>”message”. This simplifies the code and speeds up the query.

Depending on how you want to build your app- using session objects or passing the “code” GET parameter around- depends on how you are hosting your app and various browser issues. Some opt for JavaScript session management, cookie, or re-authenticating with the Code element in the query string each time. This sample app is simply two views so it’s relatively simple.

Koala’s a great lightweight framework for Facebook. In this example, I’m using 1.3.0. This is how I created the sample:

1. Created a simple rails app, “rails new koalatest”
2. Added “”koala”,”1.3.0″ to the Gemfile, ran update bundle.
3. Created “constants.rb” file in /config/initializers, and updated with my new app id and secret.
4. Copied in the two methods- index and callback- from another app I have.
5. Added the two routes, and the root route.
6. Spent quite a bit of time futzing with CSS and the View (graphcollection isn’t very intuitive)

Enjoy, and if you have any questions please feel free to comment!

More reading
Realtime facebook updates with Rails, Koala, and Resque
Rails 3 Sample App
Developing Facebook Apps Using Koala

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb

An iPhone Developer Learns Android- Some Thoughts

Posted by banane on January 16th, 2012 — in android dev, technology


At first, doing a “Hello World” was quite easy, the hardest part was learning Eclipse (for Mac):
- Open Eclipse and don’t worry about opening a project, on the left hand side will be all of your “workspace” projects.
- Running (the play button) does an automatic build
- Mouseover red squiggly underlines to find build errors

I lost one of my panes, and that took forever to learn how to open again: I still can’t confidently tell you how (sorry).

Some basics to coding in Java/Android for Eclipse:
- To log, you have a few options: import “import.android.util.Log” and write the following:
Log.e(“onestring”,”anotherstring);
You can do Log.e (error- it’s red in Log pane), “d”, or “a” (assertion).

To add resources- media, data files, etc.- in iPhone you drag resources to your project in Xcode. For Eclipse, copy to the “/res/raw” directory, with no mention anywhere else. I assume this gets indexed on compile.

Layout is still a total drag. The general idea is you can programmatically create your layout or use an XML file, and update values from code. I have to create 25 objects, so it’s programmatic. Good news- compared to iPhone, there are a lot more settings and variances. Bad news- there are different… ways of building the objects so it’s ending up being far different than my iPhone version. Still mastering things like “centering a button,” and “saving state,” “animating a fade,” etc. May give up on some of those bells and whistles for the first version.

Disappointed with file reading in Android- it’s quite easy in iphone, you can map a file directly to an NSDictionary object. I’ll include my code here for parsing a simple key,value data file.

  1. final  Hashtable<String, String> wordsHT = LoadText(R.raw.dict1a);
  2.  
  3.  
  4.         public Hashtable LoadText(int resourceId) {
  5.             // The InputStream opens the resourceId and sends it to the buffer
  6.             InputStream is = this.getResources().openRawResource(resourceId);
  7.             BufferedReader br = new BufferedReader(new InputStreamReader(is));
  8.             String readLine = null;
  9.             Hashtable<String, String> tmpHT = new Hashtable<String, String>();
  10.  
  11.             try {
  12.                 // While the BufferedReader readLine is not null
  13.                 while ((readLine = br.readLine()) != null) {
  14.                         String[] wordA = readLine.split(":");
  15.                         tmpHT.put(wordA[0], wordA[1]);
  16.                 }
  17.  
  18.             // Close the InputStream and BufferedReader
  19.                 is.close();
  20.                 br.close();
  21.  
  22.             } catch (IOException e) {
  23.                 e.printStackTrace();
  24.             }
  25.            
  26.             return tmpHT;
  27.         }

Comments welcome of course.

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb

Joy of Android: Playing Sound

Posted by banane on January 11th, 2012 — in android dev, technology

I do really like Android, unsuspectingly so. It was my New Year’s resolution to finally write an app, and I got this assignment at work to create… the quick business card app. Available in the marketplace. 10 installs in 1 day! Already an upgrade!

OK so I decided to port one of our iPhone apps- French Bingo- over to ‘droid. I immediately ran into a problem. How to play a sound. It wouldn’t play. I copied code from examples, it wouldn’t play. As in most the debugging helped me learn more about the environment, but to cut to the chase, here was the solution:

Enable the emulator to play sound. (d’oh!)

To do this:
1) Launch Eclipse (for Mac), select Run->Run Configs.
2) Select “Android Application” (left pane)
3) Select the “Target” tab in right pane.
4) Scroll down to the hidden field, “Additional Emulator Command Line Options”
5) add “-useaudio”

(Geesh). Yes, my biggest gripe so far with development is that it’s Eclipse environment on a Mac. Most documentation is for Eclipse on a PC, and things like enabling audio are too simple to mention in most blog posts or examples. So here! The internet has a blog post about it.

Here is the code for a simple example of playing a sound. My pet peeve is folks not including library/class calls, so here they are in entirity!

  1. package com.banane.bingueau;
  2.  
  3. import android.app.Activity;
  4. import android.media.MediaPlayer;
  5. import android.os.Bundle;
  6. import android.util.Log;
  7. import android.view.View;
  8.  
  9. public class BingueauActivity extends Activity {
  10.  
  11.         @Override
  12.         public void onCreate(Bundle savedInstanceState) {
  13.             super.onCreate(savedInstanceState);
  14.             setContentView(R.layout.main);
  15.          
  16.         }
  17.         public void playWord(View v){
  18.                 try{
  19.                         MediaPlayer mp = MediaPlayer.create(getBaseContext(), R.raw.salon);
  20.                         if (mp != null) {
  21.                                 mp.start();
  22.                         }
  23.                         mp.setOnCompletionListener(mCompletionListener);
  24.                 } catch (Exception e){
  25.                         //Log.d("error",e.getMessage());
  26.                 }
  27.         }
  28.  
  29.        
  30.         private MediaPlayer.OnCompletionListener mCompletionListener = new MediaPlayer.OnCompletionListener() {
  31.             public void onCompletion(MediaPlayer mp) {
  32.                 mp.release();
  33.             }
  34.         };
  35. }

My XML for the layout has a button, “word1″ with an “onClick” attribute. That’s how I’m listening for the event:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:layout_width="fill_parent"
  4.    android:layout_height="fill_parent"
  5.    android:stretchColumns="1">
  6.     <TableRow>
  7.         <Button
  8.            android:id="@+id/word1"
  9.            android:width="100dp"
  10.            android:text="@string/word1"
  11.            android:padding="3dip"
  12.            android:onClick="playWord"
  13.            />
  14.   </tablerow>
  15. </tablelayout>
  16. </xml>

Any comments/advice/thoughts are welcome of course.

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb

How to Make a Scavenger Hunt

Posted by banane on December 29th, 2011 — in games

(Scavenger hunt being: urban food & pub crawl with historical and local notes)


Team Berkeley caught near the end of San Francisco, Upper Polk Hunt 2011

1. Pick a neighborhood.
It’s pedestrian, it’s got lots of businesses close by, and it’s got “character,” that is, some identifying historical or local traditions.

2. Walk the neighborhood.
Don’t worry about route or clues, just ask yourself questions. “Why is this street named this?” Talk to locals. Ask them about “weird or interesting facts” about their neighborhood. This may get you some blank looks. I also follow with, “Why did you move/live here,” “Favorite places to go,” weird history, odd history, etc.
- get closing times and opening hours
- find weird detailed clues inside places (to prove that they’ve been there- a painting, a menu item, an odd decoration, a typo, etc.)

3. Read up on the neighborhood.
Local history books on the place, architectural books, talking to old guys- seriously- at bookstores or at local bars. I walked into The Saloon one day and asked a few regulars about how it used to be a shanghai spot (drafting poor unsuspecting drunks into serving on ships), and brothel. They corrected a few things and led me to ask questions about a brick building nearby that was an old Civil War-era jail, and hanging platform. Take time to go to lunch or walking tours with people who live there. They will be more helpful if they’re out walking- instead of sitting in a chair. This last hunt I did, about 5 clues were from a friend who had a lot of interesting questions about things. She may not have known the answer, but it led me to read up and do research. The best clues won’t be in books.

4. Do research- on the internet
I use a combination of Google maps and real printed books, but internet research is invaluable. While not authoritative, it will correct things and will help you envision the route.

5. Write a long list of clues
Don’t worry about route still, just write down every clue you think you have. Don’t worry much about the writing, just a shorthand idea of what it would be. Pick good appetizers at restaurants, specialty drinks, quirky seasonal foods, etc.

6. Work on the route.
Put hints in buckets of “requires daytime” or when the stores/shops are open. I’ve started doing mildly athletic hikes/walks in the beginning, because people are excited, and that’s the time to make them walk up hills. I also like to put my best drink place in the beginning, because folks are sober and they can really taste how good it is. For mixed kids/family crowds – I put the drink off until the middle. I love to lead people to areas they may otherwise be hesitant or shy to go- down alleys, basically. Behind things, inside shops, asking weird questions. Shake up their comfort zone. I don’t recommend doing an “8″ shaped route, as folks tend to flake, but looping back is a good idea. My most recent one was a “9″ shaped route, and at the cross-over a mini party started. It’s a good idea if it’s a large, somewhat spacious, loud place (outside grill, German restaurant, etc.) The end-up place should be somewhere that people can linger at for a long time. If they’ve completed early but want to meetup with others, for example. I’ve done an outside grill, as well as karaoke, and a Chinese restaurant.

7. Write the “nice” version of the clue: I usually do it in “3″s:
- get them to the corner
- get them inside
- figure out a detail to quiz them on

“Find the 3 arches” “Go up the alley” “turn right (north) at the 8th post” “Who wrote ___ at #29″ for example.
I have started to use compass directions along with relative ones- so “turn right” along with what N/S/E/W direction that would be. It helps in that some people like relative directions, some like compass. It’s resulted in less people being lost- because if you take one bad turn, nothing else will make sense.

I like to use a combination of empirical knowledge, research (internet use is OK on these hunts), estimation skills, pictures, word play, and cultural references. The style is based on the Chinatown Scavenger Hunt that occurs each February in San Francisco- though that one is much larger and much harder. So I’ll reference an album cover, a B Actor, Civil War knowledge, a rhebus, etc. to get a clue across. The more diversity the more fun, in a way, because it uses different knowledge in a team.

If you can use a trope all the way through a hunt, it helps. One photo of a filbert, for example, and you can refer to that in other clues.

8. Do a dress rehearsal.
Set aside 2-3 hours to do the route yourself, or with a friend who isn’t doing the real hunt. If you do have a friend like this, don’t ever offer an answer, and take your hunt with a pen to make notes. Note anything that is confusing or weird. Time the route as you go. If there are logistical issues, yep, you need to re-jigger it, and re-test. My mom helped me with the wedding hunt I did, and it really helped. We actually broke it into 2 stages, one with her, and one with myself. These dress rehearsals are invaluable. Last hunt, I found a crucial problem- my first drink spot was closed, so I moved the beginning loop up a block. It ended up fine, but it was nail-biting for a while. Good time to tlak to business owners about the specific date and time you will have it. Depending on size, they will have different reactions- I usually emphasize that not all hunters will be there at the same time, but trickling in groups of 3-5. Dress rehearsal is best done 1 week before the actual hunt, to get the same wait staff that will be on during the actual hunt. This is probably the most important tidbit in this write-up. ha.

9. Go somewhere to print the clues. I work really hard on using color photos- it’s more fun- and getting it onto one two-sided page. Then, print out enough for how many teams you expect (20? 30?) and make a lot of black and white copies for other team members. Then, there’s an official clue sheet, and cheaper ones for others to read. I get a colorful envelope and put it inside. The envelope helps teams identify other teams en route, as well as the shops, bars, and restaurants identify the scavenger hunters. This is a good thing- the more the businesses are prepared, the more welcoming they will be.

10. The actual hunt.
Make sure your cell phone is charged. Meet people at the first spot (I usually choose a cafe) and wait an hour for stragglers. I pass out clues as teams leave (so there’s no guessing around new people). I also form teams for those who don’t have one, from 3-5 people is ideal. After 45 minutes or so, I move to the next stop and get a drink, then try to move quickly through it to get to the first team. If it’s a “9″ or “8″ shaped route, I don’t do the first loop I just meetup at the midpoint with the head team. Ask folks if there are issues, and quiz them on the answers. I’ve done outside/daytime hunts on a bike (as organizer) and that is great, but walking it works too.
Don’t let them open the envelope until all team members are there and they are “starting.” It’s a rolling start (which helps people show up on time). To win- first back with all clues completed. I also check that they’ve been there, by talking to the team. Some may try to write in answers to complete it, but it’s usually quite obvious if they’ve actually been there or not.

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb

Christmas Traditions

Posted by banane on December 24th, 2011 — in nostalgia


The new “city visit” tradition with sister & kids & friends

I’m a Christmas baby. The other day, I had a conversation with my older sister Amy, who was 5 when I was born, about my mom having me. She already had 4 kids, Christmas was 4 days away. She was sick with the flu. Doesn’t that just completely suck? “She was probably in the zone. It was normal for her.” My sister said. I can’t really imagine it. My mom also does Christmas kind of over the top- lots of traditions, secrecy, myth, storytelling, magic, and … my sister again: “I also think she also made all of our gifts by hand.” I was joking with a friend last night that our Swedish Christmas traditions, while honestly sentimental by both of my parents (Swedish-American immigrants’ kids) are largely from Sunset magazine from the 60s. “My mom would have known about Swedish cooking from her Dad, and men don’t pass down those important recipes.” My friend Jeff was pissed off- “That is so sexist!” I asked him, “OK, tell me one recipe your Dad has taught you.” Jeff was quiet for a while, then, “Sloppy joes.” Not bad, but still.


My siblings while I’m being born at the hospital

For Christmas, we do the following traditions: after Thanksgiving, go chop down a tree, and gather lots of boughs. Do this on a weekend road trip to Gilroy or some small town near Santa Cruz, so Dad can continue his “backroads of America” research (another post). Find the boxes of decorations in the garage, and unwrap each one, put them around the house. The Santa mug, the nativity scene (some figurines lost- hide Jesus behind the cows), the bells, the weird one that plays the jangly out of tune carole. In California, these snowy scenes seemed at odds with our gray, relatively dry winter. Get out the Christmas piano music. Play the Christmas records.

Weave the boughs in and out of the bannisters of the stairway, on the door, everywhere. Pine needles galore. Everyone takes responsibility for their own gifts- and we give to *everyone.* There’s no limit on price. We make this french candy called “bon-bons”- buttery sugar, walnut, coconut frozen dough dipped in dark chocolate. It’s a day-long activity, and dipping each one, placing on wax paper, freezing, etc. is best with friends or more sisters. Bon-bons are usually given out to friends and family in little tins. My oldest sister Sally started this tradition: making Bûche de Noël, a French dish that’s a rolled spongecake with chocolate filling and meringue mushrooms.

Get a 100-item family Christmas list from a favorite uncle, buy a few boxes at Safeway of Christmas Cards, and start on that long process of writing little notes to everyone you’ve ever met (it seemed to me, as a kid). My parents would write long handwritten letters- my Dad was the prince of this- to his sisters, friends, and old neighbors back in the Midwest, or East Coast. The upside of all that work is receiving long letters almost every day sometimes even with pictures, of everyone and how they’re doing, reminding us of who each cousin is, who married who, who died, and pinning the card to long ribbons on the wall.

The afternoon of Christmas Eve: make Santa Lucia buns dough. This is a saffron sugary bun, that requires two different rises. Prepare dough and set to rise for an hour.

Late evening of Christmas Eve: roll out Santa Lucia buns on the big kitchen table. These are greasy orange-hued long ribbons that we roll into “s” shapes, pile on cookie sheets, put raisins in the center, let rise for another hour, then bake. After they’re done, we go to midnight mass, unless we’re running late and do these afterwards. When we get back, put out cookies and milk (though my Mom, non-dairy, likes to push that Santa is too, and he likes Scotch, water, or Diet Pepsi). Everyone goes to bed. Santa magically fills huge yard-long stockings full of toys, food, socks, soap, etc. Santa eats the food, too. Santa also piles toys for each kid (there are 5) around the living room. At this point, the quilt under the tree is bursting with wrapped presents, too.

Morning: nobody is allowed downstairs. The youngest girl, me, may go down with a small scouting team, because usually I was too young to start the oven and/or make coffee. This is a hybrid Americanization of the Santa Lucia Day- a Swedish holiday- where the youngest wears a crown of ivy with candles, and carries rolls up to her parents. INstead, we do it on Christmas morning, without the crown. So usually the most excited kid (my sister Amy) and I would go downstairs, creeping, stealing glimpses of the piles of toys, and make coffee and heat the oven, put in the rolls. We create a big tray of rolls and coffee, and carry it upstairs, usually singing our favorite carol. We all converge in Mom and Dad’s room, waiting anxiously until we get the word that we can run downstairs to open gifts.

Then, there’s about 10 hours of gift-opening. Which we do in an excruciatingly fair, turn-based method. At this point we’re also just eating Santa Lucia buns like they’re going out of style. Everyone’s un-showered, in jammies. If anyone checks the nativity scene, Jesus is magically in the barn, not hidden anymore.


It’s not over! Just when you’re stuffed with heavy saffron yeast buns, we start to cook, for reals. Big roast beef, Yorkshire pudding. My mom’s mom was British and while she couldn’t really cook, this tradition is awesome. Our Christmas dinner may have been the traditional ham for a while, but it’s shifted to a lovely huge roast beef. That’s early-ish, around 3pm, and we would invite our family friends the Richmans usually, or maybe a neighbor or two. Us kids would have to grudgingly put away our toys, or at least into neat piles, or in a big box with our name on it. A board game would start, or someone would curl up with a new book.

I, of course, had no idea other family’s didn’t do this. When brother-in-laws entered the picture, suddenly our situation looked so long and drawn out. The common melée method of random present opening still makes me kind of anxious. I want to see every gift! Revel in every opening! But I agree that the sheer amount of presents we had was mind-boggling!

Luckily we’ve adjusted to grown-up Christmasses: first was the introduction of Christmas Eve, or Christmas Day movie, by my brother, the oldest. I’m sure he was the first to return home and see the drawn out business and want some intervention. We started the Christmas Day walk- a few miles, across the street to the meadows and train tracks, the open space perserve at San Antonio park. That devolved into wandering around the unavoidable nearby cemetery, which made us depressed. In-laws made a more mixed Christmas, with additions of in-law parents, and then the alternating absence of whole sister-family. Less rigid traditions, and fine-tuning what we really liked. The addition of kids made us talk about “stockings” less, though as adults those are still very popular. We’ve added the “city visit”- a few days before Christmas, a parent & kids, maybe a grandmother, marches into the city, to see the decorations, the Macy’s, Tiffany’s windows, and the Westin’s big gingerbread castle. A late lunch, some lackadaisical shopping, and then BART home.

One year I had my parents up to my small apartment in the City, and invited them to a series of debauchery: fancy long dinner downtown, karaoke (to kill the time before midnight), then Midnight Mass. Morning with gifts, of course, and grown-up stockings: magazines, chocolate, tea, and tins of fancy herring or other exotic food from Cost Plus. Visit the sisters to get the Santa Lucia buns and examine each child’s present in the usual excruciating detail.

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb

Xcode 4 and Assigning Tab Bar Item View Controllers

Posted by banane on December 13th, 2011 — in iphone dev

I ran into this last night- I used the sample from Xcode 4, “tab bar application.” I wanted to solve this problem I was having- I was assigning a UITableViewController to one of my Tab Bar Items, but I got a crash each time, with “retavalue” and “numberOfSections.” No matter how I set it up, it continued to crash. So I decided to create a new project with just that functionality and debug it. The problem is a lingering assignment in the new IB that’s part of Xcode 4.

First, create the project, “tab bar application”

Xcode

Compile and run to test it without any modifications.

Next, create a new file that is a UIViewController, “UITableViewController” class:

Xcode2

We’re going to re-assign this to the second view on the Tab Bar. Edit some fields first-

  1. <xmp>
  2. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  3. {
  4.   return 1;
  5. }
  6.  
  7. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  8. {
  9.   return 3;
  10. }
  11. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  12. {
  13.     static NSString *CellIdentifier = @"Cell";
  14.    
  15.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  16.     if (cell == nil) {
  17.         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  18.     }
  19.    cell.textLabel.text = @"anna"; // same value repeated 3 times
  20.    
  21.     return cell;
  22. }
  23.  
  24. </xmp>

Now we have a view all set, let’s assign it to the second tab bar item, so when the user selects that, they see a table of “anna” listed 3 times.

1) Select MainWindow.xib on left side of Xcode.
2) Select the “second” tab bar item in the view. At the top you should see the “breadcrumps” and end in “second view controller”

xcode3
Uploaded with Skitch!

3. In the inspector on the right, in the “Attributes Inspector” you can see the assignment to the “SecondView” Nib name. Now, for our tableview we don’t need a NIB. We’re going to delete this. This is where the assignment lingers.

4. After deleting that, go to the next inspector tab over, “Identity Inspector” and change the “custom class” to your new UITableViewController name. Mine is “testtableview”.

xcode4
Uploaded with Skitch!

5. If you go back to “Attributes Inspector” it will still be there. Delete it again, and then click on another IB object such as the view. Click back to the Second Bar Tab Item and it will be gone. I found this by sheer experimentation. Compile and test.

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb

Penelope Trunk’s Skewed Perceptions of the World, part 2

Posted by banane on December 11th, 2011 — in feminism, technology


As usual, Penelope Trunk is fanning the flames and creating controversy (Part 1 is here). Her latest is in TechCrunch, Stop Telling Women to Start Start-ups (ironically linked to by a female start-up CEO friend of mine).

If you don’t know P. Trunk, she had a blog 10 years ago about job-hunting (based on her experience as a professional volleyball player… really). She’s founded companies but they are more extensions of her brand as a media/journalist. She’s definitely like Scoble where she’s a big personality, but not an inventor. Anyway, take that into account regarding her opinions on VC funding and start-ups.

OK back to her points, which are valid, and interesting. Her delivery detracts, I think, from getting her point across. I think her point is: we should make it easier for men to be primary caregivers of young children. Yay! Yes! But the way I wrote it- not a very sexy thesis or title.


Gasp! 20something women entrepreneurs who weren’t forced, but actually want to do it! via oobly, women in tech panel at BAIA

Granted, she tries to be kinda clear here in her first statement: “We need to get more guys who are running tech startups instead decide to be stay-at-home dads.” What? LOL. Imagine shackling Kevin Rose to the stove, and pretending Digg never happened. She’s so funny. I am pretty sure she agrees with me about making parenting more gender-neutral but instead she makes it all TechCrunchy and unnecessarily controversial. Sigh.

Here comes the part where she channels backlash feminism akin to Camille Paglia & Ann Coulter. Penelope: “If you are worried that women don’t feel capable of doing whatever they want, you can stop worrying. ” Cough. What? So many assumptions and double negatives! I think she’s responding to a concern that women feel unable to get what they want, and she’s going to negate that. We can get what we want. OK. “Women outperform men in school at such a huge rate that it’s easier to get into college as a male than a female.” So, first, believe that women outperform men in school (which school/grade, etc.? Reference?) Swallow that, then negate it again with, it’s offsetting a college admittance quota (I think that’s what she’s saying, not sure) therefore, men are being preferred? In total: we have it all ladies, quit bitchin’. And if you’re still with me, women in 20s earn more than men. That 75cents women earn per man’s dollar, the glass ceiling, etc. forget it.

While I’ve read various accounts that she refers to, I’ve also read contrary ones. It’s not scholarly or definitive, so I’m like, maybe 50% with her in believability at this point without taking into account the context, which is, she writes for a living and the most professional job she’s had was in sports.

Moving on…

“Women would probably continue out-earning men except that when men and women have kids, women choose to downshift way more often than men do.” OK now that’s interesting, and I think we’ve all read the recent studies about women under-earning progressively through their career– though some attribute it to negotiation skills and not just childcare choices.

So right when you’re back in rational land and maybe even agreeing with her, she internally links to one of her own blog posts and makes (uncomfortable squirm) the biological argument. “Men and women are different.” Really? Interesting. Not. It’s like you’re going to tell me, because I’m a girl I’m bad at math or can’t think fast enough to be a programmer.

Then I think she was like, wait, the title of my blog post is about start-ups, I need to get back to that, so she starts going on and on about women not pitching to VCs. How she’s done it, these other writers haven’t, so her opinion is better, blah blah. Kind of lost me. That is, seriously, an entirely different topic and a really interesting one, don’t get me wrong. First, you can start a company without VC money. I’m in one, my mom had one, etc. Then, in classic Trunk fashion she overshares: “But I can tell that all three times I’ve done it, raising money for a startup has been hell [ed: internal link to more oversharing], so I think we should really be asking why anyone would want to try to convince someone to do it.” It’s so like her to be personal, and bewildering. Why was it hell? Why do you continue to do it? Isn’t it biasing your argument to admit you hated it? Why did you do something you hate? On and on.

But it is a controversial topic now in start-up land, whys and wherefores of gender disparity in start-up world– from funding to being the funder. She doesn’t help understand it or present a new idea, except perhaps her first statement, that, rephrased into something boring and real, I can stand behind, except I disagree.

I think it is easy for men to be primary caregivers in this industry.

5 to 10 years ago I worked as a database and CRM consultant for large corporations. I traveled and telecommuted a lot. I worked remotely with lots of guys, almost 100% guys. It’s significant in my memory- and I’m not sure how to quantify this so I’m not going to try- but a lot of them worked from home part time and took significant roles in caring for their young children. I am positing that in the corporate world, in IT, and in the last 10 years, it is a lot easier to have non-traditional hours and working conditions, such that guys can play a 50% or higher role in childcare.

Back to the article- Penelope Trunk pisses off a lot of hard-working women in start-ups by making these outlandish generalizations. And, she’s wrong.


Penelope Trunk, an old photo I think, from TechCrunch

So at the end, she adds her spin: “Men can stay home. Women can do startups. The thing is, most don’t want to. And that’s okay.” So, in her view men don’t want to. It’s very contrary to what I have personally experienced. I’ve worked with guys who wanted to take care of their young children, and didn’t want to start a company (at this point in their lives). Sweeping generalizations- there are people OF BOTH PERSUASIONS. Let it be open, Penelope, like I think you want to convey, but fail at doing so. Let men, who want to, stay home and care for young children, let women, who want to, start companies in their child-bearing years. Voila. And, guess what! You can say this without pissing off the hardworking female entrepreneurs!!

Oh, right. TechCrunch won’t post a blog post like that, ha.

Great article: Racism and Meritocracy on TechCrunch by Eric Ries (OK sometimes they post pro-feminist stuff). By the way, I would *love* to see Penelope and Eric on a panel. Am I wrong? Who’s in!!??!!

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb

In Search of My Grandmother’s Silver

Posted by banane on December 3rd, 2011 — in nostalgia

In helping my parents downsize, I took their silver off their hands. It’s the same stuff I used to have to polish as a kid, and I remember doing that, lazy circles with a rag on a coffee pot we rarely used. So awkward now in my modern apartment, these old silver set and the big box of flatware near my front door have brought up some questions from guests- and I finally decided to find out what exactly they were. This is a rather long post about this research. It was originally an email to my siblings, but I decided others might benefit from the research, if they’re trying to date their heirlooms. What’s interesting to me isn’t so much the actual value- marketplace or sentimental- but a snapshot of an earlier America and the choices made by my grandparents and their parents, and how this is all intermeshed with American history from 1840s to now.

History of silver- “The stature of the silver teapot in America might be gleaned from the 1765 portrait of Paul Revere painted by John Singleton Copley. In the portrait, Revere, who was a silversmith, holds a silver teapot. England’s Queen Victoria (reigned 1837 to 1901) was said to prefer her tea served in a silver teapot.” From eHow History of Teapots.


This is my grandmother’s set. Roger & Bro, Co. “1701″ $97 on eBay

Baltimore 1830s coffee pot, Victorian. By Samuel Kirk / Samuel Steele.

1920s by Isadora Friedman. Modern style $5K at Christie’s (sterling silver)

Paul Revere 1768

First off, I like the Art Nouveau design of my grandmother’s more than the overly embellished detail work of Victorian (pictured upper right). Art Nouveau is largely the precursor to Modern design (bottom left). With the American Art Nouveau style, Tiffany & Co (who were early silversmiths) won the grand prize for artwork in silver, at the World’s Fair in Paris in 1878, shocking Europe. (source: “Century of Splendour”) This set is silver plate, which is frowned upon by true collectors, as it’s just a thin veneer of silver over baser metal, compared to sterling silver. It’s also massively produced, making it more available and less precious.

The silversmith stamp- (star) Rogers & Co. – has a long lineage in America. Three brothers from CT– Asa, Simeon & William– formed a silver company after two of them returned from apprenticing to a famous silversmith in 1840. Asa experimented with electroplating- later silverplating- and they started a manufacturing company. It flourished and reformed into various business entities, largely under William who was the head silversmith. (source) Later many of William Roger’s design patents were acquired from later companies.

This tea set was my grandmother’s- Edna- a dust bowl kid who came out from Missouri with her large British family. She was the oldest of either 4 or 5, and her father was a bricklayer, and while quite poor, Edna had a job at Pac Bell. According to my mom, her wedding was funded largely by herself and her new in-laws. It’s a well known story in our family that Edna bought her own wedding dress, from the set of It Happened One Night.


Edna’s dress modeled by Claudette Colbert

The tea set may have been, like the silver mirror, a gift from friend of her new in-laws, or passed down from the in-laws or friends. From my mom:

The Nelsons were pretty established in Los Angeles, were not wealthy but upper middle class. They had a lot of good friends, so, the mirror might hav been another wedding gift. Who knows, my mom could have bought it.

Edna married John Nelson, the son of a large Swedish-American middle class family. We think they got the silver flatware and a large silver mirror on their wedding day (early 1930s). This tea set, I learned on the phone while writing this blog, wasn’t a wedding gift but actually given on their 25th anniversary, in the mid-1950s. Either Edna bought it, or it was a gift she explicitly asked for. I can’t quite believe that this is from the 50s, though, so I’m thinking it was handed down from someone else- perhaps the Nelsons, or another friend. It’s psosible that she bought it at an antique store, though despite being notoriously thrifty, she did like new things.


My great-grandfather, Jöns Nelson’s house in Los Angeles, where my grandfather grew up and might have been the home of the tea set.

The pattern is “1701″ and it’s fairly common and probably sold in a department store. She was very particular about design, and since this is an older one (1910-20), she may have wanted this style as reminiscent of tea sets she saw as a child, or admired. The option to buy silver plate, instead of sterling silver, is where it gets interesting. My mother admitted that Edna and John offered to buy her and my father a sterling silver set when they married.

When we got married, the big thing was the family of the bride or groom would buy a set of sterling, that was the big deal. They talked about it, and I should have taken them up on it. Instead I got a vacuum, which I’d asked for.

So Edna would buy her daughter a far more expensive sterling silver set, but a year or so before, she bought herself (or was given) a silver-plated set. When I asked why she bought silver-plated, my mother said: “Because sterling was so expensive, plated was cheaper.” But if you’re thinking of saving money, why even buy a silver tea set? Trying to figure this out- was it prestige? Wouldn’t your guests know that it wasn’t real silver?

I will probably never know exactly what was going on with my grandmother, but in reading more about the history of the silver industry in the US and our early American history, it is interestingly enough bound up with industrialization. Early marketing by silversmiths like Tiffany & Co, and Meridian (later owners of Roger’s & Bro) tout their silver service as a sign of the changing times, of modernization and innovation:

The innovation- compared to the smokeless electric train of 1907- of quick to make and inexpensive silver. It opens up doors that later will be thrown open with the dishwasher and clothes washing machines. For homemakers, this was a chance to get the silver set that was only owned by wealthy landowners and gentry. It was a way to make the home a castle, the classic American dream.

I keep on turning over the pots to find the silver marks, and after a while, I’m getting confused- that’s because one of the pieces, the sugar bowl, isn’t like the others. I like it, it’s nicer, seems older. I think because there’s soldering instead of seams. The design seems early Edwardian, with flowered feet and edges. That silver stamp is “Biggins-Rodgers Co. Wallingford, CT” with a big D and ‘Quadruple” and “1412.”. Quadruple means that there are 4 layers of silver on top of the copper or brass core metal. According to the silvercollection.it, “BIGGINS – RODGERS CO – Willingford CT founded in 1894 by Henry E. Biggins and Frank L. Rodgers. In c. 1915-1920 the firm was succeeded by Dowd-Rodgers Co.” so this piece must have been made before 1915.

Another great resource in dating your silver is to look up the manufacturer in “http://replacements.com” and view all of the photos for each piece. Watch out, for Rogers & Co there are literally thousands of patterns. And, you need to know the pattern name. For Biggins, though, there is only one listing and one pattern, and it’s not ours, but, 1430. I can’t find this manufacturer in two comprehensive reference books on American silversmiths, but online someone wrote that they took over the Hartford Silver Manufacturing factory for the 20-year period they were in business. That is literally it for the internet. Off to call my mom.

So it is quite rare, but I’m not sure if collectors are interested. Since this was purchased when my grandmother was only 15, it’s unlikely she bought it. So here I wrote a big paragraph about how I thought the Nelsons bought it for Edna, but then my mom told me that her dad, John, picked it up as stolen merchandise from one of his cases. He was an insurance agent. Ha! So we don’t know where it came from, just somewhere around San Diego, where he worked at the time.

I honestly don’t get the whole “silver service” trend or fad. In researching this set, I find a lot of people doing exactly what I’m doing- trying to sell or value their inherited tea sets. Turns out there are a ton, literally, a ton, of silver tea sets.

What created this deluge of silver? Turns out, in the mid-1800s Europe was drowning America in silverware and hollowware (teapots, vases, etc.), and local American silversmiths couldn’t get a toehold in their own market. A few titans of the American silver industry lobbied hard to enact a tariff on imported silver, and in fact consumers had to pay for the tariff *with* silver, which increased the available silver, as well as making locally-made silver more economical. So there’s a proliferation of small silversmiths, and some large ones- such as Gorham (the White House favored silversmith) & Tiffany (leader in marketing practices & showrooms) later to become the famous jeweler. They helped America industrialize by setting up remote manufacturing plants and downtown showrooms, and changed a more lax, craft-oriented worker style to a more longer-hour, intense production (pre-assembly line) style more in common with our current 40 hour week. With World War 1, though, the maintenance of a full tea set, with regular polishing, required servants, and labor-intensive household items became less popular. Still, “… between the Civil War and World War I, American silverware production increased more than five-fold.” (see sources below: “Century of Splendor”). Modern techniques such as training manuals for salesmen, beautiful catalogs, efficient and semi-mechanized factories, all contributed to the burgeoning tradition of purchasing these tea set “heirlooms.”


Swedish 1848 silver teapot

During the late 1800s, when my great grandparents immigrated from England and Sweden, America was experiencing “new immigration,” a surge of immigration from southern and eastern Europe. Scandinavian immigration alone had reached 2.5M, a large chunk of the 18M that was US Population. While America had quickly expanded with acquisitions in the West, the populations were small compared to Eastern seaboard immigraiton, and still, British descent was the most popular. I’m trying to posit that either it seemed more “American” to have an English tea set, or it was an Old World pretentiousness- to seem like the wealthy of Sweden or England. Acquiring a silver tea set in the old world would have been nearly impossible for someone like my grandmother- without the cost-savings of American manufacturing and innovation of silver-plating, the cost would be perhaps 10x more. I’d imagine that back in England and Sweden, these items were inherited and not bought, anyway. Even if an immigrant had a set, carrying it across the Atlantic, it would doubtlessly be used to buy land or their first house, if it wasn’t stolen first. The American dream meant buying new heirlooms, oxymoronic as that sounds, or wanting to appear like you’d inherited them, as impractical or impossible as it would be.

OK now I’ll just copy and paste from this great article – which is a teaching material for an exhibit of sorts, “1840-1940 American Silversmiths: A Century of Splendour ”

Silver had traditionally been a sign of wealth and high status, and newly rich Americans found it the perfect vehicle to announce their “arrival.” Silver objects were given to mark rites of passage such as weddings, births, and anniversaries. Silver trophies were the very image of excellence and victory. Silver tea and coffee sets emphasized women’s role in the home and in social interaction, as well as one’s ability to afford the luxuries of tea, coffee, or chocolate. Perhaps most importantly for nineteenth-century Americans, matched sets of beautiful silver tableware symbolized the importance of both the home and the rituals of etiquette associated with dining. To an extent almost unimaginable today, the social act of eating had become a gauge of a person’s status and merit.

From my mom: “We brought out the silver in the dining room whenever there was a dinner party, or celebration.”

And more from “Century of Splendour”:

The use of silver in American homes changed significantly from 1900 to 1940. At the beginning of the twentieth century, wealthy and middle-class people kept large, abundantly decorated homes that served as the setting for etiquette-regulated social events. This way of life required an enormous amount of upkeep. Cleaning the house, cooking and serving the meals, waiting on guests, and polishing the silver required long hours from family members or paid servants. During the years that followed, events occurred that brought an end to this lifestyle. After World War I, the rising cost of labor and a growing distaste for service work made the habit of using a large household staff of servants difficult to continue. Reform movements stressed the desirability of clean, modern-looking homes stripped of unnecessary ornament. The Great Depression devastated middle-class incomes and made conspicuous consumption suspect. But perhaps most significantly, a new American lifestyle was developing that embraced new technologies, leisure time, and informality. As a result, ownership of silver became far less significant in American lives.

Resources & Sources:

American silversmiths
from: “Silver in America 1840-1930: A Century of Splendour”
American silversmiths & their Marks: on Google books
Encyclopedia of American Silver Manufacturers by Dorothy T. Rainwater and Judy Redfield: on Google books
Replacements.com Silver directory of manufacturers and patterns
Ruby Lane antiques forum on silver
History of the immigration to the United States, Wikipedia (and various sources)

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb

In Memoriam: Roger Richman

Posted by banane on November 5th, 2011 — in nostalgia, south bay


I lost my friend Roger yesterday. He was a kind of uncle to me, he was always there as I grew up. An expert witness in hundreds of court cases regarding how metal stood up under collision, he was a metallurgist trained in the Mining School in New Mexico, and ran a consultancy that contracted mostly with EPRI. He was incredibly smart, and an unpretentious intellectual.

He absolutely loved a well-written sentence. We shared a passion for Henry James. One book club consisted of he and I, and 3 others, sitting around a picnic table with bread, cheese and wine in Dolores Park, discussing The American. Recently Roger and I reminisced that it was our favorite book club, of the 100s we’ve had since ’93.

Regardless of what you were talking about, he would question assumptions and not let any false logic go by unexamined. Perhaps a little annoying, but once you caught onto the trick, you realized that life- conversation, discussion and examination- was very rich grounds. His son Josh does this very same conversational style, and I saw it in action last week- we were talking about Occupy Oakland. Me: “It’s funny that Jean Quan was in Washington when Obama was in San Francisco!” Josh: “Is that a bad thing?” Me: “Well she was going there to discuss it with him, and didn’t even know he wasn’t there.. do you like Quan?” (I’ve learned how to respond, haha.) Another classic Roger is that you should have an opinion, and be prepared to defend it. He and I differed on the purpose of reading. He maintained that reading should teach you something. I maintained that reading was for pleasure and sometimes discovery, but largely, mimetic. We enjoyed this difference, and debating it, frequently (to the delight of others, I’m sure.)

Roger took his wife Bev to China in 1987 for a conference, and their stories of that trip made a big impression on me. We routinely went out to Chinese restaurants in their hometown- Mountain View- largely to order an entire fish, a real delight to Roger. In fact, I think one of the reasons I was brought along was to have enough people to merit ordering a whole fish. Similar to how the Richmans adopted my family, they also adopted one of their favorite Chinese waiters, Chi-Ling, a struggling programmer who was working in a restaurant until he got a job. As Chi-Ling married and had kids, our untraditional South Bay family grew at birthdays and holidays. When I eventually travelled to China I was honored to visit with Chi-Ling’s niece Jenny, a woman very nearly the same situation as I. That kind of cultural insight was truly valuable. Roger was quite disappointed when I stopped studying Mandarin, but glad that I visited.

Being Jewish was quite important to Roger, and once when I was 16 and they took me out to dinner- at the Caravansary, a great restaurant in Palo Alto’s mall- I told him that I wanted to be Jewish too. He laughed- he had a great big kind of shocking Ha! Ha!- and told me that you’re not converted to Judaism, you just live it, like a lifestyle. There are things that you do, to be Jewish. It’s an interesting position, that he doesn’t necessarily believe in something, but that you follow the traditions. I’m sure I have this wrong and it’s not what he meant, but it’s something I’ve returned to quite a bit.

I remember noticing that my parents were grilling Roger on how he was going to vote on various South Bay bills and referendums- mostly because Roger had an opinion, and liked talking politics. I hesitate to say what he called himself, but I do remember him telling me that his grandfather (or great-grandfather?) was a real Red- bolshevik anarchist, that escaped Russia right after the revolution. His own views seemed very socialist to me, which lined up with my Dad’s socialist and Swedish upbringings. My mom was the odd one out, brought up in a staunchly Southern Californian Republican house.

He loved cigars, and asked me to buy him some on a visit to New Orleans. That led to my own love of cigars which one boyfriend managed to get me out of (thanks Elan). I loved going on a walk with a cigar or sitting in the garden. My favorite photo of him is one Bev took, that is on their wall in the hallway of their home. It’s black and white, taken at a low aperture (Bev’s a great photographer). Fuzzy, with the foreshortened cigar and Roger and his big square black glasses behind it, squinting through the smoke. I know he took a calculated risk smoking a cigar *every day* but in a way, that is our freedom- to make bad choices. He really enjoyed good wine, and luckily lived close to Ridge Wineries on Montebello Ridge. The celebration of life party his son threw was also a celebration of a hobby of amazing Ridge wine, from 87 onwards.

He loved good food- he truly enjoyed Bev’s amazing cooking- and he loved a good brisket, meatloaf, definitely into the savory or umami flavors. He wasn’t into desserts, which caused a lot of consternation when I was younger. How can that be?? Cats loved him, and he almost seemed embarrassed when they would prefer him over anyone else. He was a very steady person with a strong personality, and he will be missed.

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb

brogramming, and chickgramming

Posted by banane on October 29th, 2011 — in feminism, technology


So, uh, there’s this thing going on right now in tech, that kinda sucks. Well, it’s funny, it’s a stereotype that was created and maintained somewhat faithfully by those that fit in it. But in general, there’s an underlying tone of – let’s keep it in the club.

Brogramming on Quora
Brogramming in a job ad on y-combinator (pulled and reposted by @sarahmei on Diaspora)
Brogramming discussed in Hacker News

As I type this, the most brogrammerish person I know is a female colleague, so maybe it’s not so bad.

I’m more of a “chick-grammer”. What is that?
I usually sport etsy-style homemade knitted apparel while coding (for me, the shaped poncho, see photo)
I readily swivel to chat with coworkers ( I rarely do the headphone thing )
I drink a bottomless cup of coffee, (vs. red bull)
I bike to work and faithfully attend dance class. (vs. pumping iron)
I frequent a divy Chinatown bar where I sing karaoke )(vs. getting crunk at the club)
I wear big clear glasses, um, for prescription reasons. (vs. tinted aviator sunglasses)
I re-share kitty and baby posts. (vs. hip hop song flow charts)
I will be found at cute North Beach cafes, or sitting at kitchen table with cat in lap, which is my current position. (vs. huddled up with blanket on couch)
I like working in 3-4 hour stints with breaks for food, socializing and exercise. (vs. all nighters)

Photo credit to Carina for the photo of Chris Turitzin in my shaped poncho sweater- available for $20!

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • TwitThis
  • YahooMyWeb