Posted by & filed under Content - Highlights and Reviews, programming, Programming & Development, Tech, Web Development.

by Sam Phippen

Sam Phippen

Sam Phippen has been writing software for more than seven years. He routinely gives conference talks about software design and testing and currently serves the Ruby community as a member of the RSpec core team. Sam regularly contributes to Open Source Ruby applications and works as a consultant at Fun and Plausible Solutions. He is the presenter of the recently released video course called “Effective Ruby” from Addison-Wesley Professional


The Hash class is one of the most widely used in Ruby. We use it to represent everything from parameters objects, to database rows, and even domain specific data structures. In this post, we’ll explore a number of specific ways that you can improve your use of hash objects to make better rails applications.

Preferring Hash#fetch over Hash#[]

The most common way to get values from a hash is to use the square brackets, or subscript, method. This method directly looks up the value under the passed key in the hash and returns the value stored under the key in the hash. If the key is not found, [] instance method returns nil.

So let’s talk about fetch. On first inspection, the fetch method is similar to the [] method:

Unlike the [] method, the fetch method raises an exception if the key being looked up is not found.

This behavior of fetch is very useful. Primarily, it means that you can find key places where data values are missing in your system with ease. It may be the case that you sometimes want to provide a default value, even when the hash does not contain a value stored under that key. With [] you may be used to ||ing the value in, using the nil as the missing value behavior. fetch makes this easy and explicit.

Instead of having a separate (||) syntax for providing a default the fetch method provides us with an explicit way of doing this. Fetch actually has three signatures:

  • fetch(key) which raises an exception if the provided key is not found
  • fetch(key, default) which returns the provided default value if the provided key is not found
  • fetch(key) { ... } which evalutes the provided block and returns its return value if the key is not found.

Read more »

Posted by & filed under work culture.

Clothing has always been important to me, and while I’ve never been a particularly trendy dresser, I’ve always cared about what I wear and how I present myself.

As a high school student I developed an eccentric sense of style that culled from Army Navy stores, flea markets, thrift stores, and my grandmother, which earned me the dubious title of “best dressed” from my choir. (Long live art kids.) Fast forward almost ten years and I still have a penchant for ripped tights, messy hair, weird fitting cardigans, and massive scarves, so dressing appropriately for work is a continuous challenge for me, even in a casual environment like Safari.

Below, some things I’ve learned:

1. Choose a color palette and develop a uniform

I chose black as my color palette because black is versatile, dynamic, and simple. While black clothing can be difficult to match together, (never assume that two black pieces are going to match!) they are also easy to accessorize, look more polished, wash better, and generally wrinkle less than light colored clothing. Also, if you are like me, all your white dresses will have coffee stains, which are fortunately easily covered with large scarves. (Just kidding!)

NYMag ran a series of excellent posts on stylish women and uniforms, and I largely echo those sentiments. Wearing a uniform has made getting dressed in the morning easier and infinitely more chic.

2. Purge often

I had bedbugs in college, which meant I had to get rid of a fairly large collection of hideous patterned 1980s sweaters collected from years of thrifting.

At the time I was devastated, but now I see that experience as a blessing because it taught me the importance of purging my clothes often. Are your favorite pair of pants pilled beyond recognition? Do you have dresses that look wrinkled no matter how many times you iron them? What’s sitting in the back of your drawer that you never wear? Give these clothes to charity, sell them to a consignment shop, or have a clothes swap with your friends: there’s no reason to hold onto things you don’t wear, and getting rid of clothing means you have more room for the things you actually feel good in.

3. Accessorize

Accessories are an easy way to make every outfit feel more complete, from scarves to statement necklaces to big vintage rings. I inherited a large collection of scarves from my grandmothers, and I scour vintage stores, flea markets, and consignment sales for costume jewelry. I also try to buy simple, inexpensive pieces from local designers at small boutiques in the area.

I rarely leave the house without jewelry and a subtle perfume. A distinctive scent can help you feel more polished. (I wear Jo Malone 154.) If you’re scent sensitive, I highly recommend finding an organic essential oil you enjoy. A few drops can make the whole day brighter.


Working it at work

4. Quality always trumps quantity

While we live in an age of fast fashion, you can find well-made clothes for less if you take some time to think about your buying values. While I occasionally buy for convenience, I also am extremely aware of the quality of my clothes due to years of trawling consignment stores for top designers like Marc Jacobs and Chloe.

Good quality clothing doesn’t have to be expensive.. Brass, a local Boston startup that works directly with factories to provide high quality garments for less, ran a piece last year about how to judge quality in clothing, and I’ve found it helpful when shopping for work clothes.

5. Never buy retail

Like one of my fashion role models, Fran Fine, I would never buy retail. (Particularly if my “cousin” was Todd Oldham!)

For better or worse, most retailers exist in a constant sales model where it’s easy to patiently wait for a piece to go slightly out of season in order to get a deal. My focus on sales has helped me find some amazing pieces from high-end designers for much less than their original price. 

6. Don’t forget your shoes

I am from a “shoe family” (I’m the first in three generations not to work in the women’s shoe business!) so shoes are clearly important to me. With shoes, price does reflect quality and comfort, so it’s worth investing in a few good pairs that you can wear for a long time.

Also, meet your local cobbler and make friends! If you love a pair of shoes and wear them out they can usually be fixed.

Read more »

Posted by & filed under authoring, programming.

Now in its third year, National Novel Generation Month is a whimsical offshoot of the wildly popular National Novel Writing Month. NaNoGenMo participants write a computer program that outputs a “novel” of at least 50,000 words. (There is no official definition of “novel”—any 50,000 words qualify.) The Verge had a good roundup of the 2014 entries.

Last year, I wrote a program that generated a nonsense book inspired by the mysterious 16th century Voynich Manuscript. This year I took inspiration from one of the earliest known works of computer-generated fiction, the little-known SAGA II.

Read more »

Posted by & filed under Business, content, curation, Digital Publishing, education technology, libraries, PubFactory, publishing, Safari News.

This Friday, Nov. 6, 2015 – I will contribute to a content curation panel at the Charleston Library Conference along with Will Schweitzer, Director, Product Development at the American Association for the Advancement of Science (AAAS) and Michael Levine-Clark, Interim Dean and Director, University of Denver Libraries. The focus of the panel is to examine the challenge and value of content curation from a technology perspective, a publisher perspective, and a librarian’s perspective, and how we can work together to solve that challenge.

We will discuss different ways to surface the most relevant and the most desired content to the user(s) seeking it. From the point of view of a platform provider, this is not a challenge that can be answered strictly through technological means, but rather one that requires a combined effort by platform providers and by publishers. The publisher effort is specifically needed to provide metadata and additional content in order to fully leverage the technology tools available within online publishing platforms.

Getting users to content involves two basic capabilities, both of which require both the full text content and a certain amount of metadata to work properly:

  • Robust search capabilities which are the  first and most obvious way to lead the user through the site.
  • Browsing and linking which further guides users through the site to related content pages.  There are many different ways to present these links which each have their own needs in terms of the metadata necessary to drive the process. For example, links to content in the same journal or book, related links through keywords, and subject browsing through taxonomies have all been traditionally used to provide linked pathways to similar content.

Read more »

Posted by & filed under microservices, search.


This post explains the technical choices we made while refactoring our search feature from a component within a monolithic Django project into a microservice. It explores our efforts to break dependence on a shared database, use central authentication and plan for redundancy, among other things.

I hope that by sharing in detail some of these choices, including our mistakes, I will help you on your own refactoring project. I know that I can’t shield you completely, but perhaps in the course of your project someone will mention renaming a few curiously-named fields or rewriting the JavaScript front-end, and you’ll get a twinkle in your eye and think of me.

www.safaribooksonline-4Why a microservice?

If the hype hasn’t already deafened you, a “microservice” is basically a narrowly-focused web service. In theory, this narrowness should make them easier to understand than more complex projects. When they split a software product like Safari across well-defined boundaries, they are supposed to allow teams to change pieces of the product independently.

At Safari we want to go fast, and in our experience speed tends to decrease as teams and codebases grow. So, like a lot of engineering teams, we’re trying out microservices to see if they help us go faster.

If you want to learn more about microservices, check out Sam Newman’s book Building Microservices or, if you favor video, The Principles of Microservices by the same author.

Read more »

Posted by & filed under Business, Content - Highlights and Reviews, innovation, Tech.

Screen Shot 2015-11-02 at 5.35.16 PM

In his recently released book, Disrupting Digital Business: Create an Authentic Experience in the Peer-to-Peer Economy” (Harvard Business Review Press, May 2015), author R Ray Wang makes it clear that we are no longer in an economy of products and services. The digital transformation demands that we focus our attention on experiences and outcomes. Organizations must pivot with and ahead of social, organizational, and technological shifts or risk being left behind.

He makes the case that the the most successful companies moving forward are the ones that embrace a new way of thinking around these major trends:

  • Consumerization of technology and the C-suite
  • Data’s influence in driving decisions
  • Digital marketing transformation
  • The future of work
  • The matrix commerce

We asked Wang a few questions a few questions about his book:

What are the main characteristics of the digital transformation that’s taking place, and how is it affecting organizations?

The biggest shift is the urgency that’s required to make the change in business models, not technologies.  The business models have to align with the organization’s brand promise.  We see successful digital transformation when we humanize digital. Successful companies take a Board-driven, management-led, and employees-engaged approach. Culture beats tech in digital transformation. Read more »

Posted by & filed under Content - Highlights and Reviews, java, programming, Programming & Development, Tech.

by Trisha Gee

Trisha Gee is the author of the new video series called “Building Java 8 Web Applications with Microservices” from Addison-Wesley Professional.

If you’re a Java developer you’ll have heard about lambda expressions making their way into Java SE 8. You might not be aware, however, that there’s much more to Java 8 than a new arrow operator. In this article we’re going to look at how lambda expressions and other new features in Java 8 will make your life as a developer easier.

Lambda expressions

The shift in mindset that lambda expressions encourages is the idea of passing behaviour around, not just objects. For example, you can give a method a piece of code to execute:

The Service class contains all the boilerplate needed to instantiate a new web sockets service. It’s a very simple service that connects to a server endpoint (“ws://localhost:8081/tweets/”) that provides data to consume, and starts its own server endpoint (“/users/”, 8083) where it publishes data.  The final parameter is our lambda, which tells our micro-sized service what the business logic is – consume Twitter messages, extract the Twitter username and publish it.

Before lambdas, you might have had copy-and-paste coding as you copy all the service boilerplate code and replace the business logic section for each new service. Or you might have an abstract service class that you override for each individual service. With lambdas, you can be much clearer about separating the infrastructure-level Service code and its business logic. Read more »

Screen Shot 2015-10-29 at 10.51.31 AM

Posted by & filed under career advice, careers, content, Content - Highlights and Reviews, Daily Learning, growth, learning, Learning & Development.

I’m a modern learner. And whether you know it or not, you’re probably one, too.

You might be asking: “What is a modern learner?” Well, from the looks of it, a modern learner is anyone working in an industry or organization that requires any or all of the following:

  • Continuous advancement of existing skills
  • Rapid learning of a diverse array of new skills and knowledge
  • Frequent application of, and experimentation with, those new skills and knowledge
  • Constant honing of critical thinking, leadership, and collaborative skills to tackle increasingly complex challenges and opportunities
  • Disruptive innovation that gives your business a competitive edge 

… all which must be accomplished in tandem with getting the job done and contending with the barrage of information, pings, and requests that beg for one’s attention throughout each day.

Here’s a great infographic depicting the modern learner. While the possibilities for professional and personal growth are exhilarating, it’s clear to see they are also overwhelming. And a little bit mind blowing. And more than a little distracting.

So what is a modern learner to do? Read more »

Posted by & filed under Content - Highlights and Reviews, javascript, programming, Programming & Development, Tech, Web Development.

by Richard Feldman

Richard Feldman is a functional programmer who specializes in pushing the limits of browser-based UIs.  He works at NoRedInk building education tools using Elm and React. He is also one of the authors of the upcoming second edition of “Developing a React Edge: The Javascript Library for User Interfaces” from Bleeding Edge Press. The second edition of that book will be available in Safari as an early release title in the near future.

For years, in the world of JavaScript UI programming, it’s been normal to divide our application state among several components, with each component owning its own local state. With the architectures of the past this was essentially unavoidable, but the rise of React and declarative rendering has opened the door for a more powerful paradigm to take hold: the single state atom.

Now that more and more JavaScript libraries are abandoning local component state in favor of the single state atom, certain questions have begun to arise. Can we control which portions of the single state atom nested components can access? Is it possible to make reusable components without giving them ownership over their own state? Could we implement an entire application like this using React 0.14’s functional stateless components?

Perhaps most importantly: now that we have a strong ecosystem that can support a single state atom, has local component state gone from a best practice to an alluring trap? Read more »

Posted by & filed under Content - Highlights and Reviews, programming, Programming & Development, python, Tech.

By Daniel Arbuckle

Daniel Arbuckle is a computer scientist and software engineer who has worked with, studied, and built a career around Python starting with version 1.5. He is the author of multiple books and videos on Python for Packt Publishing.

Mastering Python  Python Testing  Learning Python Testing


Python’s first steps toward an implementation of coroutines came in December 2001 with the release of Python 2.2. At that time, generators were added to the language and Python 2.5 made it easier to use generators as coroutines by changing the yield statement into an expression which also made it easier to send information into a generator as the result of a yield expression.

Now, Python 3.3 made it even easier to use generators as coroutines thanks to a new yield from syntax.

As of Python 3.4, the asyncio framework is part of the standard library and generator-based coroutines were part of the toolkit. Asynchronous execution in a single thread is great for I/O scheduling and lightweight threading. Now, asyncio gives us all of that in one convenient package.

All of which brings us to the recent release of Python 3.5, which includes an explicit coroutine type, distinct from generators, new asynchronous async def, async for, and async with statements, and an await expression that takes the place of yield from for coroutines.

Why does Python need explicit coroutines and new syntax if generator-based coroutines had become strong enough for inclusion in the standard library? The short answer is that generators are primarily for iteration, so using them for something else (no matter how well it works conceptually) introduces ambiguities. For example, if you hand a generator to Python’s for loop, it’s not going to treat it as a coroutine but instead as an iterable. Read more »