Search suggestions with Solr using multiple analyzers

There are some great new search suggestion (aka autocomplete) features showing up in Lucene and Solr. The Solr documentation hasn’t quite caught up, so I thought sharing my experience might be helpful to others working on using these features. The Solr features build on capabilities added to Lucene which are described well in a series of blog posts by Lucene guru Mike McCandless starting with this one, but it still requires a bit of finagling to decide exactly how to use these features.  I’ll describe our use case, and present some interesting extensions I needed in order to get things working just how we wanted.

Continue reading

Using your iPad to learn about Android?

Android has been trending in the news because of this recent Gartner report, showing the Google OS as the clear number one among new tablet sales in 2013, surpassing iOS.

Not surprisingly, the subject of Android development has been steadily rising in popularity in Safari Flow. During 2013, Android was the twelfth most popular topic among Safari Flow users. During the first two months of 2014, it climbed to our ninth most popular topic. And the week following the release of the Gartner study (March 3), Android surged to the sixth most popular topic. “Android” is also the sixth most common search term since the beginning of the year.

But it’s difficult to ignore the irony that the vast majority of our Flow users sign in with their Apple mobile devices to learn about Android. Of all the visits from mobile devices to Safari Flow, the iOS share increased from 56.7% in 2013 to 62.4% in 2014. Android devices, meanwhile, have dipped slightly from 41.2% of the visits in 2013 to 35.8% in 2014.

Getting started in Android development?

On Wednesday, we’ll offer five tips to help you get started with Android development. Follow our blog (click + on the bottom right of this page) to get a reminder when the post is live.

In the meantime, check out our Android topic page to get a sampling the most popular books and videos about Android. And here are three titles released this year that we highly recommend:

image of book cover
Android: How to Program, January 2014

by Paul Deitel, Harvey Deitel, and Abbey Deitel

 

 

image of book cover


Android Recipes: A Problem-Solution Approach, February 2014

by Dave Smith and Jeff Friesen
 

 

image of book cover
Learning Android, January 2014

by Marko Gargenta and Masumi Nakamura

What publishing needs from the web (and how you can help)

For a few months now I’ve served as co-chair of “DPUB”, the W3C Digital Publishing Interest Group, (with Markus Gylling, who somehow has time to be a wonderful CTO of two different standards organizations). DPUB acts as a channel for those of us in digital publishing to influence the development of web standards like HTML5 and CSS3. The group has already produced two public documents describing use cases for text layout and for annotations, which we’re quite proud of. But we’d like to do more, and we need your help.

Let us know what interests you (and please join the public mailing list).
Continue reading

All of a Sudden – Tech

We’ve all heard stories about career changes “later in life,” and while I’m still enjoying some level of healthy denial as I move swiftly into my fiftieth year on the planet, I find myself apparently living one of these tales.

About a year ago, I decided that I needed something more from a career. I had been working as a Realtor for twelve years and while I enjoyed many aspects of the job, I was not thrilled with the idea of selling myself to really build the business; I’ve never been the handshaking, salesman type, ready to draw out a business card like a pistol at a shoot-out. It’s just not me – it was all I could do to remember to have my business cards with me.

carMy predicament became a topic at a barbecue one afternoon, and a friend asked if I had ever heard of “Salesforce” or a “Salesforce Administrator” – I had not. In fact, I had absolutely no background in the tech industry or anything remotely related. The closest I came to any experience was a basic programming class I completed as a college freshman (back in the Computer Cretaceous Period). I was also something of a math “whiz kid” in high school (see: “Woulda Coulda Shoulda”) but other than these brief brushes – nothing.

What followed the barbecue exchange were a series of conversations and online research over a few weeks until I was convinced and interested enough to take the first training, Administration Essentials for New Admins (ADM-201). I was intrigued by learning something entirely new and interested in the puzzle solving and detective work it seemed would be required as a Salesforce Administrator; I love to unravel problems and hunt for solutions – this was really what motivated me to take that first step – the challenge of it all.

The ADM-201 training is a relatively soft exposure to the Salesforce Customer Relationship Management (“CRM”) platform’s environment. In the exercises, you set-up the users and systems, complete customizations, and set access, among many other things, for a mock corporation’s platform (or the “org.”). A problem I noted right away with the first training is that the Fauxecutives who submit requests do so in almost perfectly articulated Salesforce-speak; in other words, in the real world I knew that issues and requests would not be so perfectly worded. Salesforce Administrators are not just detectives – they are translators, as well.

mouseThat said, my first training was a healthy introduction to the environment and I subsequently sat for the certification test. Common knowledge holds that there is a 60% average failure rate for the first test, a fact that I knew going in and that caused my right eye to twitch slightly; but I passed the first time – and was reassured that, although the hamster in my head may have … um … matured … and played on a rusty wheel, he could still run. Phew!

Once I had my new certification in hand, I updated my LinkedIn profile and really very little else. I did poke around online about how to get into the biz, but no one offered a viable way. I live in rural west Sonoma County and the job market here is limited, at best. For a while it seemed my career change had stalled. I thought, “Now what?”

Four months passed and then suddenly – an email arrived – my LinkedIn profile update had been noticed and well, the rest is (recent) history. Here I sit as a new Salesforce Administrator at an amazing company, Safari Books Online, right in my hometown – and I love it.

Once in, it quickly became clear that I would need more than the somewhat cursory pass at Salesforce that the ADM-201 modules had provided. So, in early March, I completed Building Applications with Force.com (DEV-401) at the Salesforce University, located on the 3rd floor of the Salesforce mother ship in San Francisco. (Turns out, there is an “ice cream floor” at headquarters (It’s Its! All three flavors!), but I’ve been sworn to secrecy as to the exact location – sorry.)

The overarching theme of the DEV-401 training was building Force.com applications. We learned how to create custom objects, fields, lookup relationships, master-detail relationships, lookup filters, applications and tabs and most importantly, learned the differences between these components. We studied the relationships between objects in-depth, with the help of charts, an exercise and a student guide, and solid instruction.

We drilled deeper into our training org., creating layouts, formula fields, cross-object formulas and roll-up summary fields. This section of the training increased our understanding of field dependencies, object relationships (Parent-Child) and how these settings can impact the overall user experience.

We continued by completing exercises designed to provide a clearer understanding of the Salesforce sharing model, with training in Organization-Wide Defaults, Role Hierarchy, Public Groups, Sharing Rules and Apex Sharing Reasons. This section was very helpful and will be key to furthering my understanding of how to provide the appropriate access to end users in our real world org.

sfWe then learned how to embed images directly in records and created hyperlinks. We also looked at data security, and practiced with Validation Rules and field level security settings; these are important aspects to understand as they help to protect the quality and integrity of the data.

A very interesting portion of the training, which I believe will be of direct benefit, were the areas we covered regarding Workflow Rules. The takeaway was that many of our current processes that are now hard-coded could have been easily accomplished declaratively with Workflows and Tasks – a slogan at Salesforce is “Clicks not Code,” and now I know why. The question remains; can these simple point-and-click solutions work now with the code currently in place in the background? We shall see.

The remainder of the training focused on Visualforce, which provides the ability for a Developer to customize the UI that the end user sees. We moved into understanding and creating Flows (simple input frameworks), which I don’t feel will ultimately be that useful but it did expose me to aspects of the platform I didn’t know existed; they’re kind of fun, too! It might be nice, at some point, to create a Flow for new Leads or Account entry through a user-friendlier process for our Sales Reps., for example.

In this module, we also created a Visualforce page relative to our training org., adding new templates, images and web content. This required learning some basics with regard to writing Apex code, and I found this really engaging and interesting. I picked-up several handy tips that will help a lot as I do my detective work with regard to our Apex code. As a beginner, this portion of the training really lit a fire in my belly and fueled my desire to learn more.

binaryTo summarize in the abstract, the DEV-401 class revealed the “Why?” of components and systems that exist in the Salesforce platform, whereas the ADM-201 training is really just an introduction to the core environment and exposure to some basic principles (the “What?” and the “How?”).

I had an excellent instructor in the DEV-401 training, Leah McGowen-Hare, who really took the time to illustrate in simple terms some of the very complex and deeply buried features of Salesforce – she used an entire wall of the room, covering it with diagrams, thereby grounding otherwise cryptic concepts – I’ve never witnessed such skilled use of Dry Erase Markers.

classI feel much more equipped and confident now as I move forward. It also became clear, as a result of our complex business processes and amount of hard-coding here at the home office, that I am already performing development-level work as opposed to basic Administrator tasks, and that realization has helped a lot with my confidence.

The next best training for me would be Introduction to Object-Oriented Programming with Force.com (ADM-231, formerly DEV-531), which is more in-depth with regard to writing/understanding Apex code, and follow that with Apex & Visualforce Controllers (DEV-501) some time in the future.

Until then … may the Salesforce be with you.

greyhoundP.S. It also helps that Safari Flow offers some great titles to help me with my journey. I particularly enjoyed Salesforce.com® For Dummies®, 4th Edition, which is a good way to start exploring the Salesforce universe (actually, it’s more of a multiverse). Another engaging text to check-out is Teach Yourself VISUALLY Salesforce.com, which offers a unique training approach – sort of like a firm handshake between the left and right sides of the brain.

Teaching Physical Computing with Arduino

groupshot

David, Theo, Me, Josh, Kazu, Roberta & Archer

Recently, my infatuation with Raspberry Pi, Arduino, and Physical Computing coincided nicely with Safari Books Online’s dedication to ongoing education and involvement with ConnectEd. Having volunteered at Seabury Hall in Makawao, Hawaii (Maui) in the past, I was given the opportunity to submit an idea for a “Winterim” 4-day workshop on the topic of my choice. If enough students signed up, I would spend a week in Maui teaching the workshop (and have a few days on the beach, of course).

Bill is busy turning his workshop into a free Arduino Bootcamp, which will be featured here on the Flow blog. If you’d like to be notified when it starts, follow us on Twitter, Facebook, or Google+.

Realizing that Raspberry Pi may be a little too finicky for middle schoolers, I shifted my attention to Arduino. I turned to Safari Flow to learn Arduino myself, and then used it to build a syllabus that matched my own educational journey and discovery curve. After submitting my proposal to the school, I anxiously waited to hear how many students I would get. The fact that alternative workshops were on topics such as sailing, canoeing, hiking, and windsurfing didn’t help my anxiety! I was pleased when I learned that 6 students had signed up. Almost immediately, I started receiving questions from the enthusiastic students, such as “Can I bring in my box of junk electronics to make a robot?” and “Can we hack my remote control car?” Once I saw those questions, I knew we were going to have a great week.

With the books and videos that I had in Flow and a few rather large orders from Maker Media and Adafruit, I was able to gather enough course material to ensure that we eased into programming and electronics while laying a strong foundation for tinkering, setting up the students for continued learning beyond the 4-day workshop.

An overview of my workshop is below, and in the near future I’m planning to share specific chapters and videos that were useful to me. I’m hoping that our story and pictures below will inspire you to use the material to support students of your own.

Day 1: Basic Circuits and Blinking LEDs

Kazu sets up

Kazu had the most complex breadboards, but somehow always knew exactly which wire went where, and what it did!

On the morning of the first day, we built some basic circuits without a microcontroller to get a feel for prototyping circuits using tactile buttons, potentiometers, force sensitive resistors, and ambient light sensors. In the afternoon we went over to the lab to demonstrate how a microcontroller can do many things with the same basic circuits, using code to modify blink patterns, blink durations, and multiple LEDs. After some more light coding, we were able to play a melody using a piezo-buzzer via pulse-width modulation.

Day 2: More Inputs and Outputs

Josh

Josh prepares to upload a sketch

On day two, we used a third-party library and switch statements to decode signals via an infrared receiver, which listened for commands from universal remotes to control various outputs. We were able to switch on LEDs, control servos, and change colors of an RGB LED. We learned to read and sketch schematics and dug into basic programming concepts like switch and if/else statements and for loops. We also got a lot of practice mashing up code samples from books with our own code and modifying them to achieve our desired functionality.

Day 3: Field Trip

Drones in the courtyard

Drones in the courtyard

Unfortunately, I don’t have pictures from the field trip (the exact location is “classified,” sort of), but we saw a web-controllable telescope, which was part of the DoD telescope array for tracking US and foreign satellites. We also got to check out the Boeing electrical systems integration room, where there were “real live” electrical engineers designing and soldering circuits to create custom, rack-mounted motor controllers for various telescopes. In the afternoon, we built “brush bots” from a toothbrush, vibration motor, coin-cell batteries, and LEDs. We then let the bots fight it out. We also took turns flying a Parrot AR drone!

Day 4: Show and Tell

Archer demonstrates arming and disarming his intruder alarm with a universal remote

Archer demonstrates arming and disarming his intruder alarm with a universal remote

On the final day, each student combined what he or she had learned to build a personal project. Here are some examples of what they came up with. It was amazing to see what they were able to design in a 5-hour day after only 2.5 days of instruction:
  • A temperature probe that turns on an LED when the temperature exceeds 23° Celsius
  • A game that challenges you to press a button as many times as you can (counted on a 7-segment display) until your toast pops up, as detected by a PIR motion sensor
  • A fortune-telling “magic” 8-ball: Ask it a question and push a button on the remote, which triggers a servo pointer to randomly move back and forth before stopping at a response on the dial
  • A motion-activated intruder alarm that can be armed/disarmed via remote control
  • A motion-activated intruder alarm that plays a threatening melody with a buzzer when motion is detected

Special Thanks to Jaqueline Peterka and Roberta Hodara at Seabury Hall in Makawao, Hawaii, for making this happen!

Scala Macros that won’t kill you

One of the many things that bothers me about Java is the lack of compile-time checking.  I don’t want to have to run my program to know if the URL is well-formed, if a file exists, or if an email is valid.

Scala offers a solution.  Scala macros allow essentially arbitrary computations to run at compile time.  Let’s walk through the simple email example:

Getting started

First let’s define a simple email class with the to string we are all expecting:

case class Email(val local: String, val domain: String) extends NotNull {
override def toString() = local + "@" + domain
}

case classes” are one of the best features of Scala.  They define immutable final classes with predictable default implementations for equality, hash values, and to string.  They also have pattern-matching support.

We can construct an Email like:

val email = Email("someone", "hotmail.com")

Adding readability

Scala also offers string interpolation so we can make these statements more readable:

val email = email"someone@hotmail.com"

Where at runtime Scala will essentially call an email function with the string.

EmailHelper.email("someone@hotmail.com")

We just need a little Scala magic for that to happen:

implicit class EmailHelper(val sc: StringContext) extends AnyVal {
def email(args: Any*) =  Email(args(0).before(“@”),args(0).after(“@”))
}

Now the magic happens

Now this may seem like adding a lot of complexity for a small improvement in readability.  The real win comes from adding compile time-validation.

First we need to add some more magic with the macro keyword:

implicit class EmailHelper(val sc: StringContext) extends AnyVal {
def email(args: Any*): Email = macro EmailHelperimpl
}

and then define the function that will be called at compile time

def EmailHelperimpl(c: Context)(args: c.Expr[Any]*): c.Expr[Email] = {
import c.universe._
//...
}

args will be a sequence of abstract syntax trees.  Scala macros work on the level of the AST so it is effectively impossible to produce a syntax error (unlike C/C++ macros).  c.Expr[Email] says that we will return an abstract syntax tree with type Email:

c.prefix.tree match {
  // access data of string interpolation
  case Apply(_, List(Apply(_, rawParts))) =>
   //...
  case _ =>
  c.abort(c.enclosingPosition, "invalid")  // TODO: change this to a sensible default
}

We can pattern match on the AST with Apply(_, List(Apply(_, rawParts))), where the underscores act as wildcards.  We only care about the first specific case.  If somehow things are different, we register an error with the compiler.

You can register errors with c.abort and warnings with c.warning.

When we have what we want, we can build the String AST fragment into a list of strings and their positions:

val parts = rawParts map { case t @ Literal(Constant(const: String)) => (const, t.pos)

This step is necessary because there are some more complicated string interpolation use cases.  For now we only care when we have have the case of one string.

parts match {
  case List((raw, pos)) => {
  //...
  }

  case _ =>
    c.abort(c.enclosingPosition, "invalid")
  }
}

I hid the email validation logic in EmailParser (the details aren’t that interesting):

Email.EmailParser.parse(raw) match {
  case Errors(errors) => {
    for (error <- errors) {
      c.error(pos, error.msg)
    }
    reify { Email("", "") } // not valid
  }
  case Result(Email(local, domain), warnings) => {
    for (warning <- warnings) {
      c.warning(pos, warning.msg)
    }
    reify {
      Email(
        (c.Expr[String] { Literal(Constant(local)) }.splice),
        ((c.Expr[String] { Literal(Constant(domain)) }.splice)))
    }
  }
}

reify is a magic function that constructs an AST for literal Scala code.  And that’s it!

Getting the code and examples

Because of the quality of the Scala IDE, it is possible to develop this in real time.  You don’t even need to trigger a compile.

There are many cases where Java and other languages use strings as a proxy for distinctly non-string data (regular expressions are an obvious example).  So I built up some more validators for common Java types.

These examples and others are available in my source code.

Intro to Python Bootcamp – Session 5

Welcome to session 5 of our Introductory Python “Bootcamp,” our week-long blog series that explores the key concepts behind this popular and flexible programming language.

New to the bootcamp? Start with Session 1.

Open a Safari Flow trial account to access the Bootcamp books and videos.

Bootcamp header- Intro to Python Day 5

Welcome to the home stretch!

Over the past four sessions, you have learned the fundamental building blocks of Python. In Session five, you will synthesize what you have learned in order to solve different real-world problems. We will introduce ways of working with databases and effective debugging, and focus on exercises that apply all of the concepts taught in sessions 1-4.

Putting it all together

Start with these short videos.

From Python Guide for the Total Beginner LiveLessons

From Quickstart Python

Test your mettle

Now try your hand at these capstone exercises from Learn Python the Hard Way.

Screen Shot 2013-12-11 at 10.17.53 PM

Congrats! You have successfully completed the Safari Flow Introductory Python Bootcamp! Job well done!

We want to hear from you!

We’d love to hear your feedback about this bootcamp or other topics you’d like to learn. Tell us what you think in the comments below.

Intro to Python Bootcamp – Session 4

Welcome to session 4 of our Introductory Python “Bootcamp,” our week-long blog series that explores the key concepts behind this popular and flexible programming language.

New to the bootcamp? Start with Session 1.

Open a Safari Flow trial account to access the Bootcamp books and videos.

Bootcamp header- Intro to Python Day 4

Warm up

Before we dive into today’s new content, we are going to start by going deeper into classes and OOP, concepts introduced in Session 3.

Try your hand at these exercises from Learn Python the Hard Way.

Screen Shot 2013-12-11 at 10.17.53 PM

Now onto the new stuff – modules and documentation.

Jump in the deep end

Start with these short videos.

From Python Guide for the Total Beginner LiveLessons

From Quickstart Python

Let’s start typing

Next, check out three chapters from Python® Programming for the Absolute Beginner. Following along, you will build a trivia game, create a “Critter Caretaker” program, and enter the world of online gambling with your own Blackjack game.

Practice more of what you learned with these exercises from Learn Python the Hard Way. (Pro tip: it’s not really hard!)

Get inspired

Did you know that Safari Flow gets the official videos from all of the O’Reilly conferences? This means that if you missed Fred Wilson’s keynote at this year’s Velocity Conference or couldn’t make the definitive conference on data science, then you can watch each inspiring and informational talk while in your pajamas from your laptop. Each conference includes dozens of talks, from the inspirational to the highly tactical.

Too easy?

To go deeper in any of these topics, here are some great reference chapters, all taken from O’Reilly’s Learning Python, 5th Edition.

lrg

How are we doing?

We’d love to hear your feedback about this bootcamp or other topics you’d like to learn. Tell us what you think in the comments below.

Also, if you have friends who might want to learn Python and join the bootcamp, let them know! Follow us on Twitter and be sure to Like our new Facebook page.

Intro to Python Bootcamp – Session 3

Welcome to session 3 – the halfway point – of our Introductory Python “Bootcamp,” our week-long blog series that explores the key concepts behind this popular and flexible programming language.

Open a Safari Flow trial account to access the Bootcamp books and videos.

In Session 2, we continued working with variables, control flow, and data structures to build a few simple apps, include a game called “Guess my number.” We also talked about “How to create a culture of shipping product continuously” and asked “Do we have the tools we need to navigate the new world of data?”.

New to the bootcamp? Start with Session 1.

If you are new to Safari Flow, sign up today for a free 10-day trial and learn Python for free!

Ready to get started?

Bootcamp header- Intro to Python Day 3

In session 3, we are going introduce functions, classes, and object oriented programming (OOP), all cornerstones of Python.

Jump in the deep end

Start with these short videos.

From Python Guide for the Total Beginner LiveLessons

From Quickstart Python

Let’s start typing

Next, check out the following chapters from Python® Programming for the Absolute Beginner. Following along, you will build a word jumble, a game of hangman, and a tic-tac-toe application.

Practice more of what you learned with these exercises from Learn Python the Hard Way. (Pro tip: it’s not really hard!)

Get Inspired

Today, you’re learning Python. In a year from now you’re the CTO of your own startup. What do you need to know?

Operations 101, a five-video series developed by O’Reilly in partnership with Etsy, will give you a good introduction to tech operations. From troubleshooting outages to application level monitoring, this is a great primer on managing the technical operations of a growing company.

Too easy?

As you go through these exercises, you may realize that you need to go deeper in some topics. Here are some great reference chapters, all taken from O’Reilly’s Learning Python, 5th Edition.

lrg

That’s it for Session 3! Congrats you more than half way done!

Ready for Session 4?

How are we doing?

We’d love to hear your feedback about this bootcamp or other topics you’d like to learn. Tell us what you think in the comments below.

Also, if you have friends who might want to learn Python and join the bootcamp, let them know! Follow us on Twitter and be sure to Like our new Facebook page.